讀取設定檔
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
完成「準備使用 People API」一文中的步驟後,您就可以讀取設定檔的資料。
以下程式碼範例示範如何傳送幾個簡單的要求。如需完整的方法清單,請參閱參考說明文件。
取得已驗證使用者的人員
如要取得使用者設定檔,請使用下列程式碼:
通訊協定
GET /v1/people/me?personFields=names,emailAddresses HTTP/1.1
Host: people.googleapis.com
Java
Person profile = peopleService.people().get("people/me")
.setPersonFields("names,emailAddresses")
.execute();
Python
profile = people_service.people()
.get('people/me', personFields='names,emailAddresses')
PHP
$profile = $people_service->people->get(
'people/me', array('personFields' => 'names,emailAddresses'));
.NET
PeopleResource.GetRequest peopleRequest =
peopleService.People.Get("people/me");
peopleRequest.PersonFields = "names,emailAddresses";
Person profile = peopleRequest.Execute();
取得 Google 帳戶 ID 的使用者資訊
如要取得 Google 帳戶 ID 的使用者資訊,請使用以下程式碼:
通訊協定
GET /v1/people/account_id?personFields=names,emailAddresses HTTP/1.1
Host: people.googleapis.com
Java
Person profile = peopleService.people().get("people/account_id")
.setPersonFields("names,emailAddresses")
.execute();
Python
profile = people_service.people()
.get('people/account_id', personFields='names,emailAddresses')
PHP
$profile = $people_service->people->get(
'people/account_id', array('personFields' => 'names,emailAddresses'));
.NET
PeopleResource.GetRequest peopleRequest =
peopleService.People.Get("people/account_id");
peopleRequest.PersonFields = "names,emailAddresses";
Person profile = peopleRequest.Execute();
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-11-23 (世界標準時間)。
[[["容易理解","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-11-23 (世界標準時間)。"],[[["This page provides code samples demonstrating how to read profile data using the People API after completing the initial setup."],["You can retrieve the authenticated user's profile, including names and email addresses, using the provided code snippets."],["The guide also includes code examples for fetching profile information for a specific Google Account ID, specifying the desired person fields."]]],["The provided code samples demonstrate how to retrieve profile data using the People API. Users can get the authenticated user's profile by sending a `GET` request to `/v1/people/me` or retrieve a profile by Google Account ID using `/v1/people/\u003caccount_id\u003e`. Both requests use the `personFields` parameter, specifying `names,emailAddresses` to filter for those specific fields. Different languages are exemplified such as Java, Python, PHP and .NET, showing how to form the API request.\n"]]