Google Health API ช่วยให้คุณเข้าถึงข้อมูลด้านสุขภาพและสุขภาวะที่ผู้ใช้ส่ง
ข้อมูลโปรไฟล์ผู้ใช้จะพร้อมใช้งานผ่านปลายทาง
getProfile แต่จะจำกัดเฉพาะเมตริก เช่น อายุและวันที่เริ่มเป็นสมาชิก
หากต้องการดูข้อมูลโปรไฟล์ผู้ใช้เพิ่มเติม ให้ใช้
People API คุณอาจต้องขอการให้สิทธิ์สำหรับ
ขอบเขตเพิ่มเติม เช่น หากต้องการอ่านวันเกิดของผู้ใช้ คุณต้องใส่
https://www.googleapis.com/auth/user.birthday.read และ
https://www.googleapis.com/auth/userinfo.profile ในคำขอการให้สิทธิ์ ดูข้อมูลเพิ่มเติมเกี่ยวกับการให้สิทธิ์ People API ได้ที่ให้สิทธิ์คำขอ
ตัวอย่างเช่น หากต้องการรับวันเกิดของผู้ใช้โดยใช้ People API ให้ทำดังนี้
โปรโตคอล
GET /v1/people/me?personFields=birthdays HTTP/1.1 Host: people.googleapis.com
Java
Person profile = peopleService.people().get("people/me") .setPersonFields("birthdays") .execute();
Python
profile = people_service.people() .get('people/me', personFields='birthdays')
PHP
$profile = $people_service->people->get( 'people/me', array('personFields' => 'birthdays'));
.NET
PeopleResource.GetRequest peopleRequest = peopleService.People.Get("people/me"); peopleRequest.PersonFields = "birthdays"; Person profile = peopleRequest.Execute();
การตอบกลับ
{ "resourceName": "people/115549...", "etag": "%EgQBBy43...", "birthdays": [ { "metadata": { "primary": true, "source": { "type": "DOMAIN_PROFILE", "id": "115549..." } }, "date": { "month": 1, "day": 1 } }, { "metadata": { "source": { "type": "ACCOUNT", "id": "115549..." } }, "date": { "year": 1990, "month": 1, "day": 1 } } ] }