Reputation: 199
I am getting the below response from the google contact API :
SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => http://schemas.google.com/contacts/2008/rel#edit-photo
[type] => image/*
[href] => https://www.google.com/m8/feeds/photos/media/username%40domain.com/3f800ef08589236/I_BQwBZUKwmNsRvSkFXR-A
)
)
SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => http://schemas.google.com/contacts/2008/rel#photo
[type] => image/*
[href] => https://www.google.com/m8/feeds/photos/media/username%40domain.com/3f800ef08589236
)
)
SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => self
[type] => application/atom+xml
[href] => https://www.google.com/m8/feeds/contacts/username%40domain.com/full/3f800ef08589236
)
)
SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => edit
[type] => application/atom+xml
[href] => https://www.google.com/m8/feeds/contacts/username%40domain.com/full/3f800ef08589236/1396967693060001
)
)
But I am not able to fetch the image using this data, can anyone please let me know how can I get the contact image using this data?
Upvotes: 0
Views: 577
Reputation: 1
use the following where $client is the Object of Google_Client();
foreach ($temp['feed']['entry'] as $image) {
if (isset($image['link'][0]['href']))
{
$photo=new Google_HttpRequest($image['link'][0]['href']);
$photo_val=$client->getIo()->authenticatedRequest($photo);
$photo_return=$photo_val->getResponseBody();
$imgData=base64_encode($photo_return);
$pro_image='data:image/jpeg;base64,'.$imgData .'';
}
}
Upvotes: 0
Reputation: 1880
It's the href in the 2nd Object you've got listed there. Send an authenticated request to that URL and you'll get the photo.
Upvotes: 1