Google api Google联系人API:如何获取Google API联系人图像?
我从google contact API获得以下回复:Google api Google联系人API:如何获取Google API联系人图像?,google-api,google-contacts-api,google-client,Google Api,Google Contacts Api,Google Client,我从google contact API获得以下回复: SimpleXMLElement Object ( [@attributes] => Array ( [rel] => http://schemas.google.com/contacts/2008/rel#edit-photo [type] => image/* [href] => https://www.goog
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
)
)
但是我无法使用此数据获取图像,请任何人告诉我如何使用此数据获取联系人图像 这是您列出的第二个对象中的href。向该URL发送经过身份验证的请求,您将获得照片 使用以下命令,其中$client是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 .'';
}
}