我在检索用户联系人的图像时遇到了一个简单的问题。所以我提出了一个请求
$url = 'https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=9999&oauth_token=' . $accessToken;然后我得到了巨大的JSON,我从其中提取了全名和电子邮件。然后我试着获取联系人的图像,但没有任何成功。
我接触到了所有的联系人,每个人都有以下结构:
entry [id, updated, category, title, link, gd$email].在link部分,我得到了四个链接,其中前两个是指向图像内容的某种链接,但我无法检索它。
任何人都能成功地完成这项工作!?
Tnx很多!
顺便说一句:如果我的案例中的一些数据丢失了,请报告,我也会添加的!
编辑:我也尝试过通过URL访问图片
http://profiles.google.com/s2/photos/profile/" + userid + "?sz=" + size;但问题是我不能从contacts JSON获取userId。
发布于 2015-02-16 22:43:54
发布于 2015-02-26 20:12:58
如果所提到的标签可用,请按如下所示再次发出请求。
$add = new Google_HttpRequest("https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&max-results=500&access_token='.$token->access_token");
$add->setRequestMethod("GET");
$add->setRequestHeaders(array('GData-Version' => '3.0', 'content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
$submit = $client->getIo()->authenticatedRequest($add);
$sub_response = $submit->getResponseBody();
$temp = json_decode($sub_response, true);
foreach ($temp['feed']['entry'] as $image) {
$google_contact_id = $image['link'][2]['href'];
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 . '';
}
}https://stackoverflow.com/questions/19403056
复制相似问题