I am trying to get a photo of a contact using the Google Contacts API as per this document . Used PHP Client library here . I get the code and information about the user successfully, but could not get data about the user's photo.
I got the answer:
Photo request failed - invalid contact id
.
This is the PHP code of the callback function that I use to get the user's photo data:
$client = new Google_Client();
$client->setClientId(GOOGLE_APP_CLIENT_ID);
$client->setClientSecret(GOOGLE_APP_CLIENT_SECRET);
$client->setRedirectUri(GOOGLE_APP_CLIENT_REDIRECT_URI);
$client->addScope("openid profile email https://www.google.com/m8/feeds");
$oauth2 = new Google_Service_Oauth2($client);
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_code'] = $client->getAccessToken();
$client->setAccessToken($_SESSION['access_token']);
$temp_obj = $client->verifyIdToken();
....
$guser_info = $oauth2->userinfo->get();
$contact_id = $guser_info['id'];
$user_email = $guser_info['email'];
$req = new Google_Http_Request("https://www.google.com/m8/feeds/photos/media/default/$contact_id");
$val = $client->getAuth()->authenticatedRequest($req);
print_r($val->getResponseBody());
} ...
I included Contacts APIthe console in the project and added an area https://www.google.com/m8/feeds.
id Contact ID - ?
.