อ่านโปรไฟล์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หลังจากทำตามขั้นตอนในหัวข้อเตรียมพร้อมใช้งาน People API แล้ว คุณก็พร้อมที่จะอ่านข้อมูลโปรไฟล์
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีส่งคําของ่ายๆ 2-3 รายการ ดูรายการวิธีการทั้งหมดได้ในเอกสารอ้างอิง
ค้นหาบุคคลสำหรับผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์
หากต้องการรับโปรไฟล์ของผู้ใช้ ให้ใช้รหัสต่อไปนี้
โปรโตคอล
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 ของบุคคลนั้น
หากต้องการรับข้อมูลบุคคลสำหรับรหัสบัญชี Google ให้ใช้รหัสต่อไปนี้
โปรโตคอล
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();
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-11-23 UTC
[[["เข้าใจง่าย","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 UTC"],[[["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"]]