使用者個人資料

Google Health API 可讓您存取使用者提交的健康與保健資料。使用者個人資料資訊可透過 getProfile 端點取得,但僅限於年齡和會員開始日期等指標。

如要取得其他使用者個人資料資訊,請使用 People API。您可能需要要求其他範圍的授權。舉例來說,如要讀取使用者的生日,您必須在授權要求中加入 https://www.googleapis.com/auth/user.birthday.readhttps://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
      }
    }
  ]
}