2013-10-16 3 views
5

사용자의 연락처 이미지를 검색하는 중 간단한 문제가 있습니다. 그래서Google 연락처 API - 이미지 가져 오기

$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]. 

링크 섹션에서, 나는 처음 두 이미지 콘텐츠에 대한 링크의 일종있는 네 개의 링크를 가지고 있지만 검색 할 수 없습니다 그것.

어떤 몸이라도 이런 종류의 일을 성공적으로 마쳤습니다!

Tnx 많이!

동의어 : 내 사례의 일부 데이터가 누락 된 경우 신고 해 주시면 추가하겠습니다.

편집 : 나는 또한 URL

http://profiles.google.com/s2/photos/profile/" + userid + "?sz=" + size; 

와 이미지에 도달하기 위해 노력했지만 문제는 연락처 JSON에서 사용자 ID 얻을 수있다.

+0

https://developers.google.com/google-apps/contacts/v3/#retrieving_a_contacts_photo 왜하지 않습니다이 작품? "id"가 필요한 contactID가 아닌가요? – awaigand

+0

문제는 연락처 ID가없는 것입니다. JSON에 필드 ID가 있습니다. http://www.google.com/m8/feeds/contacts/adrian.1358%40gmail.com/base/10161fe0e87a941 " – Adrian

+0

JSON의 링크 부분에도"https://www.google.com/m8/feeds/photos/media/adrian.1358%40gmail.com/10161fe0e87a941/1B2M2Y8AsgTpgAmY7PhCfg "와 같은 링크가 있습니다. – Adrian

답변

-1

아래에서 설명한 태그가 사용 가능한지 다시 한 번 확인하십시오.

$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 . ''; 
    } 
}