ユーザーのプロフィール情報

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
      }
    }
  ]
}