I'm currently working with Google_Client api and want to fetch User Name, Phone, Email and User address.
I set-up these scopes:
'https://www.googleapis.com/auth/plus.login',
'https://www.googleapis.com/auth/user.birthday.read',
'https://www.googleapis.com/auth/user.addresses.read',
'https://www.googleapis.com/auth/user.emails.read',
'https://www.googleapis.com/auth/user.phonenumbers.read'
And when I click on the login with google it asks the correct permissions, and then I fetch the access token with the code provided by Google.
After getting the token I request for people_service
and profile data like this:
$token = $this->client->fetchAccessTokenWithAuthCode($_GET['code']);
$people_service = new \Google_Service_PeopleService($this->client);
$profile = $people_service->people->get(
'people/me',
array('personFields' => 'addresses,birthdays,emailAddresses,phoneNumbers')
);
It returns a Google_Service_PeopleService_Person
object.
But when I try to use method on it like getPhoneNumbers()
it returns a Call to undefined method Google_Service_PeopleService_Person::getNames()
error.
What is the problem and what can I do?