บริการ People ขั้นสูงช่วยให้คุณสามารถใช้
People API ใน Apps Script API นี้ช่วยให้สคริปต์สร้าง อ่าน และอัปเดตข้อมูลติดต่อของผู้ใช้ที่เข้าสู่ระบบ รวมถึงอ่านข้อมูลโปรไฟล์ของผู้ใช้ Google ได้
ข้อมูลอ้างอิง
สำหรับข้อมูลโดยละเอียดเกี่ยวกับบริการนี้ โปรดดูที่
เอกสารอ้างอิงสำหรับ People API
เช่นเดียวกับบริการขั้นสูงทั้งหมดใน Apps Script บริการ People ขั้นสูงจะใช้
ออบเจ็กต์ เมธอด และพารามิเตอร์เดียวกันกับ API สาธารณะ ดูข้อมูลเพิ่มเติมได้ที่วิธีกำหนดลายเซ็นของเมธอด
/** * Gets a list of people in the user's contacts. * @see https://developers.google.com/people/api/rest/v1/people.connections/list */functiongetConnections(){try{// Get the list of connections/contacts of user's profileconstpeople=People.People.Connections.list('people/me',{personFields:'names,emailAddresses'
});// Print the connections/contactsconsole.log('Connections:%s',JSON.stringify(people,null,2));}catch(err){// TODO (developers) - Handle exception hereconsole.log('Failedtogettheconnectionwithanerror%s',err.message);}}
/** * Gets the own user's profile. * @see https://developers.google.com/people/api/rest/v1/people/getBatchGet */functiongetSelf(){try{// Get own user's profile using People.getBatchGet() methodconstpeople=People.People.getBatchGet({resourceNames:['people/me'],personFields:'names,emailAddresses'
// Use other query parameter here if needed});console.log('Myself:%s',JSON.stringify(people,null,2));}catch(err){// TODO (developer) -Handle exceptionconsole.log('Failedtogetownprofilewithanerror%s',err.message);}}
/** * Gets the person information for any Google Account. * @param {string} accountId The account ID. * @see https://developers.google.com/people/api/rest/v1/people/get */functiongetAccount(accountId){try{// Get the Account details using account ID.constpeople=People.People.get('people/'+accountId,{personFields:'names,emailAddresses'
});// Print the profile details of Account.console.log('PublicProfile:%s',JSON.stringify(people,null,2));}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failedtogetaccountwithanerror%s',err.message);}}