קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
שירות 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);}}
אחזור של האדם שמשויך למשתמש
כדי לקבל את פרופיל המשתמש, צריך לבקש את ההיקף 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('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);}}
[[["התוכן קל להבנה","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"]],["עדכון אחרון: 2024-12-21 (שעון 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."]]],[]]