קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
שירות האנשים המתקדם מאפשר לכם להשתמש ב-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('Failed to get the connection with an error %s',err.message);}}
קבלת האדם עבור המשתמש
כדי לקבל את פרופיל המשתמש, צריך לבקש את היקף ההרשאות https://www.googleapis.com/auth/userinfo.profile. לשם כך, פועלים לפי ההוראות להוספת היקפי הרשאות מפורשים לקובץ המניפסט appsscript.json. אחרי שמוסיפים את ההיקף, אפשר להשתמש בקוד הבא:
/** * 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('Failed to get own profile with an error %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('Public Profile: %s',JSON.stringify(people,null,2));}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failed to get account with an error %s',err.message);}}
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-08-04 (שעון UTC)."],[[["The advanced People service in Apps Script utilizes the People API to manage contact data for the logged-in user and access Google user profiles."],["This advanced service needs to be enabled before use and mirrors the functionality of the public People API."],["Scripts can create, read, and update contact details for the current user, as well as retrieve profile information for other Google users."],["Sample code snippets are provided to demonstrate functionalities like fetching user connections, retrieving the user's own profile, and getting information for any Google Account by ID."]]],[]]