Membaca Profil

Setelah menyelesaikan langkah-langkah di 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 yang diautentikasi

Untuk mendapatkan profil pengguna, gunakan kode berikut:

Protokol

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();

Mendapatkan ID Akun Google orang tersebut

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

Protokol

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();