Class User

ผู้ใช้

ผู้ใช้ที่เชื่อมโยงกับไฟล์ใน Google ไดรฟ์ ผู้ใช้เข้าถึงได้จาก File.getEditors(), Folder.getViewers() และวิธีอื่นๆ

// Log the email address of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getEmail());
}

วิธีการ

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
getDomain()Stringรับชื่อโดเมนที่เชื่อมโยงกับบัญชีของผู้ใช้
getEmail()Stringรับอีเมลของผู้ใช้
getName()Stringเรียกดูชื่อผู้ใช้
getPhotoUrl()Stringรับ URL สำหรับรูปภาพของผู้ใช้

เอกสารประกอบโดยละเอียด

getDomain()

รับชื่อโดเมนที่เชื่อมโยงกับบัญชีของผู้ใช้

// Log the domain names associated with all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getDomain());
}

รีเทิร์น

String — ชื่อโดเมนที่เชื่อมโยงกับบัญชีของผู้ใช้


getEmail()

รับอีเมลของผู้ใช้ ที่อยู่อีเมลของผู้ใช้จะใช้ได้เฉพาะเมื่อผู้ใช้เลือกที่จะแชร์ที่อยู่จากหน้าการตั้งค่าบัญชี Google+ หรือผู้ใช้อยู่ในโดเมนเดียวกับผู้ใช้ที่เรียกใช้สคริปต์และผู้ดูแลระบบโดเมนอนุญาตให้ผู้ใช้ทั้งหมดภายในโดเมนเห็นที่อยู่อีเมลของผู้ใช้รายอื่นได้

// Log the email address of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getEmail());
}

รีเทิร์น

String — อีเมลของผู้ใช้หรือสตริงว่างหากที่อยู่อีเมลไม่พร้อมใช้งาน


getName()

เรียกดูชื่อผู้ใช้ เมธอดนี้จะแสดงผล null หากไม่มีชื่อผู้ใช้

// Log the names of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getName());
}

รีเทิร์น

String — ชื่อผู้ใช้ หรือ null หากไม่มีชื่อผู้ใช้อยู่


getPhotoUrl()

รับ URL สำหรับรูปภาพของผู้ใช้ เมธอดนี้จะแสดง null หากรูปภาพของผู้ใช้ไม่พร้อมใช้งาน

// Log the URLs for the photos of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getPhotoUrl());
}

รีเทิร์น

String — URL สำหรับรูปภาพของผู้ใช้ หรือ null หากไม่มีรูปภาพ

วิธีการที่เลิกใช้งานแล้ว