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