خدمة الأشخاص المتقدمة
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتيح لك خدمة People المتقدّمة استخدام
People API في "برمجة التطبيقات". تتيح واجهة برمجة التطبيقات هذه للنصوص البرمجية إنشاء بيانات جهات الاتصال للمستخدم الذي سجّل الدخول وقراءتها وتعديلها، كما تتيح قراءة بيانات الملف الشخصي لمستخدمي Google.
مراجع
للحصول على معلومات مفصّلة حول هذه الخدمة، يُرجى الاطّلاع على المستندات المرجعية الخاصة بواجهة People API.
مثل جميع الخدمات المتقدّمة في Apps Script، تستخدم خدمة People المتقدّمة الكائنات والطُرق والمعلَمات نفسها التي تستخدمها واجهة برمجة التطبيقات العامة. لمزيد من المعلومات، اطّلِع على كيفية تحديد تواقيع الطرق.
للإبلاغ عن مشاكل والعثور على معلومات مفيدة أخرى، يُرجى الاطّلاع على دليل دعم الإصدار 1 من People API.
نموذج التعليمات البرمجية
يستخدم نموذج الرمز البرمجي أدناه الإصدار 1 من واجهة برمجة التطبيقات.
الحصول على جهات اتصال المستخدم
للحصول على قائمة بالأشخاص في جهات اتصال المستخدم،
استخدِم الرمز التالي:
الحصول على الشخص المناسب للمستخدم
للحصول على ملف المستخدم، عليك طلب النطاق https://www.googleapis.com/auth/userinfo.profile
باتّباع التعليمات لإضافة نطاقات صريحة إلى ملف البيان appsscript.json
. بعد إضافة النطاق، يمكنك استخدام الرمز التالي:
الحصول على حساب Google الخاص بالشخص
للحصول على معلومات المستخدم لأي حساب على Google،
استخدِم الرمز التالي:
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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,["# Advanced People Service\n\nThe 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---------\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-----------\n\nThe sample code below uses [version 1](/people/api/rest) of the API.\n\n### Get 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```javascript\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\n### Get 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```javascript\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\n### Get 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```javascript\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```"]]