با مجموعهها، منظم بمانید ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
سرویس پیشرفته People به شما امکان می دهد از People API در Apps Script استفاده کنید. این API به اسکریپتها اجازه میدهد تا دادههای تماس را برای کاربر وارد شده ایجاد، خواندن و بهروزرسانی کنند و دادههای نمایه را برای کاربران Google بخوانند.
مرجع
برای اطلاعات دقیق در مورد این سرویس، به مستندات مرجع برای People API مراجعه کنید. مانند همه سرویسهای پیشرفته در Apps Script، سرویس پیشرفته افراد از همان اشیا، روشها و پارامترهای 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);}}
تاریخ آخرین بهروزرسانی 2025-08-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe advanced People service in Apps Script utilizes the People API to manage contact data for the logged-in user and access Google user profiles.\u003c/p\u003e\n"],["\u003cp\u003eThis advanced service needs to be enabled before use and mirrors the functionality of the public People API.\u003c/p\u003e\n"],["\u003cp\u003eScripts can create, read, and update contact details for the current user, as well as retrieve profile information for other Google users.\u003c/p\u003e\n"],["\u003cp\u003eSample 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.\u003c/p\u003e\n"]]],[],null,["The advanced People service allows you to use the\n[People API](/people) in Apps Script. This API allows scripts\nto create, read, and update contact data for the logged in user and read profile\ndata for google users.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n\nFor detailed information on this service, see the\n[reference documentation](/people/api/rest) for the People API.\nLike all advanced services in Apps Script, the advanced People service uses the\nsame objects, methods, and parameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[People v1 support guide](/people/support).\n\nSample code\n\nThe sample code below uses [version 1](/people/api/rest) of the API.\n\nGet the user's connections\n\nTo [get a list of people in the user's contacts](/people/api/rest/v1/people.connections/list),\nuse the following code: \nadvanced/people.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/people.gs) \n\n```gosu\n/**\n * Gets a list of people in the user's contacts.\n * @see https://developers.google.com/people/api/rest/v1/people.connections/list\n */\nfunction getConnections() {\n try {\n // Get the list of connections/contacts of user's profile\n const people = People.People.Connections.list('people/me', {\n personFields: 'names,emailAddresses'\n });\n // Print the connections/contacts\n console.log('Connections: %s', JSON.stringify(people, null, 2));\n } catch (err) {\n // TODO (developers) - Handle exception here\n console.log('Failed to get the connection with an error %s', err.message);\n }\n}\n```\n\nGet the person for the user\n\nTo [get the user's profile](/people/api/rest/v1/people/get), you need to request\nthe `https://www.googleapis.com/auth/userinfo.profile` scope by following the\n[instructions to add explicit scopes](/apps-script/concepts/scopes#setting_explicit_scopes)\nto your `appsscript.json` manifest file. Once the scope is added, you can use\nthe following code: \nadvanced/people.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/people.gs) \n\n```gosu\n/**\n * Gets the own user's profile.\n * @see https://developers.google.com/people/api/rest/v1/people/getBatchGet\n */\nfunction getSelf() {\n try {\n // Get own user's profile using People.getBatchGet() method\n const people = People.People.getBatchGet({\n resourceNames: ['people/me'],\n personFields: 'names,emailAddresses'\n // Use other query parameter here if needed\n });\n console.log('Myself: %s', JSON.stringify(people, null, 2));\n } catch (err) {\n // TODO (developer) -Handle exception\n console.log('Failed to get own profile with an error %s', err.message);\n }\n}\n```\n\nGet the person for a Google Account\n\nTo [get the person information for any Google Account](/people/api/rest/v1/people/get),\nuse the following code: \nadvanced/people.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/people.gs) \n\n```gosu\n/**\n * Gets the person information for any Google Account.\n * @param {string} accountId The account ID.\n * @see https://developers.google.com/people/api/rest/v1/people/get\n */\nfunction getAccount(accountId) {\n try {\n // Get the Account details using account ID.\n const people = People.People.get('people/' + accountId, {\n personFields: 'names,emailAddresses'\n });\n // Print the profile details of Account.\n console.log('Public Profile: %s', JSON.stringify(people, null, 2));\n } catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed to get account with an error %s', err.message);\n }\n}\n```"]]