People API'yi Kullanmaya Hazırlanma bölümündeki adımları tamamladıktan sonra profillerle ilgili verileri okumaya hazırsınız demektir.
Aşağıdaki kod örnekleri, birkaç basit isteğin nasıl gönderileceğini göstermektedir. Yöntemlerin tam listesi için referans dokümanlarını inceleyin.
Kimliği doğrulanmış kullanıcının kimliğini alma
Kullanıcı profilini almak için aşağıdaki kodu kullanın:
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')
$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 Hesabı kimliği için kullanıcıyı alma
Bir Google Hesabı kimliğiyle ilgili kullanıcı bilgilerini almak için aşağıdaki kodu kullanın:
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')
$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();