Чтение профилей
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
После выполнения шагов, описанных в разделе «Подготовка к использованию People API» , вы готовы читать данные для профилей.
Следующие примеры кода демонстрируют, как отправить несколько простых запросов. Полный список методов смотрите в справочной документации .
Получить человека для аутентифицированного пользователя
Чтобы получить профиль пользователя , используйте следующий код:
Протокол
GET /v1/people/me?personFields=names,emailAddresses HTTP/1.1
Host: people.googleapis.com
Ява
Person profile = peopleService.people().get("people/me")
.setPersonFields("names,emailAddresses")
.execute();
Питон
profile = people_service.people()
.get('people/me', personFields='names,emailAddresses')
PHP
$profile = $people_service->people->get(
'people/me', array('personFields' => 'names,emailAddresses'));
.СЕТЬ
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
Ява
Person profile = peopleService.people().get("people/account_id")
.setPersonFields("names,emailAddresses")
.execute();
Питон
profile = people_service.people()
.get('people/account_id', personFields='names,emailAddresses')
PHP
$profile = $people_service->people->get(
'people/account_id', array('personFields' => 'names,emailAddresses'));
.СЕТЬ
PeopleResource.GetRequest peopleRequest =
peopleService.People.Get("people/account_id");
peopleRequest.PersonFields = "names,emailAddresses";
Person profile = peopleRequest.Execute();
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. 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"]]