Membaca Profil

Setelah menyelesaikan langkah-langkah dalam Bersiap Menggunakan People API, Anda siap membaca data untuk profil.

Contoh kode berikut menunjukkan cara mengirim beberapa permintaan sederhana. Untuk mengetahui daftar lengkap metode, lihat dokumentasi referensi.

Mendapatkan orang untuk pengguna terautentikasi

Untuk mendapatkan profil pengguna, gunakan kode berikut:

Protocol

GET /v1/people/me?personFields=names,emailAddresses HTTP/1.1
Host: people.googleapis.com

Java

Person profile = peopleService.people().get("people/me")
    .setPersonFields("names,emailAddresses")
    .execute();

Python

profile = people_service.people()
    .get('people/me', personFields='names,emailAddresses')

PHP

$profile = $people_service->people->get(
    'people/me', array('personFields' => 'names,emailAddresses'));

.NET

PeopleResource.GetRequest peopleRequest =
    peopleService.People.Get("people/me");
peopleRequest.PersonFields = "names,emailAddresses";
Person profile = peopleRequest.Execute();

Dapatkan ID Akun Google orang tersebut

Guna mendapatkan informasi orang tersebut untuk ID Akun Google, gunakan kode berikut:

Protocol

GET /v1/people/account_id?personFields=names,emailAddresses HTTP/1.1
Host: people.googleapis.com

Java

Person profile = peopleService.people().get("people/account_id")
    .setPersonFields("names,emailAddresses")
    .execute();

Python

profile = people_service.people()
    .get('people/account_id', personFields='names,emailAddresses')

PHP

$profile = $people_service->people->get(
    'people/account_id', array('personFields' => 'names,emailAddresses'));

.NET

PeopleResource.GetRequest peopleRequest =
    peopleService.People.Get("people/account_id");
peopleRequest.PersonFields = "names,emailAddresses";
Person profile = peopleRequest.Execute();