2017-09-21 16 views
0

Google Contacts API에서 사진을 가져올 수 없습니다. 다음은 내가 사용한 코드입니다.JS를 사용하여 Google Contacts API에서 사진을 얻는 방법

gapi.client.request({ 
method: 'GET', 
path: '/m8/feeds/photos/media/default/1f27ce8913181e', 
headers: { 
     "Content-Type":"image/*", 
     "GData-Version": "3.0", 
     "if-match":"*", 
     "data":token, 
} 
}).then(function(result){ 
    console.log(result); 
}) 

콘텐츠 유형에서 JSON과 XML을 모두 시도했습니다. 또한 위의 URL에 access_token을 추가했습니다. 그래서이 이미지를 얻도록 도와주세요.

미리 감사드립니다.

+0

"할 수 없다"는 것은 무엇을 의미합니까? 오류가 있었습니까? 문제가 무엇인지 자세히 설명하십시오. – zero298

+0

Google에서 응답을 받았는데 상태는 404입니다. 이미지의 바이트가 없습니다. –

답변

0

Retrieving a contact's photo를 참조하십시오

가 연락처의 사진을 링크 URL에 인증 된 GET 요청을 보내, 연락처의 사진을 검색 할 수 있습니다.

의 URL의 형식은 : USEREMAIL 및 ContactID가 대신 적절한 값으로

https://www.google.com/m8/feeds/photos/media/{userEmail}/{contactId} 

.

Note: The special userEmail value default can be used to refer to the authenticated user. 
The photo link can be retrieved from the contact entry returned by the API: 

<entry xmlns="http://www.w3.org/2005/Atom" 
    xmlns:gContact="http://schemas.google.com/contact/2008" 
    xmlns:gd="http://schemas.google.com/g/2005" 
    gd:etag="{contactEtag}"> 
    <id> 
    http://www.google.com/m8/feeds/contacts/{userEmail}/base/{contactId} 
    </id> 
    ... 
    <title>Full Name</title> 
    <gd:name> 
    <gd:fullName>Full Name</gd:fullName> 
    </gd:name> 
    <link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" 
    href="https://www.google.com/m8/feeds/photos/media/{userEmail}/{contactId}" 
    gd:etag="{photoEtag}"/> 
    <link rel="self" type="application/atom+xml" 
    href="https://www.google.com/m8/feeds/contacts/{userEmail}/full/{contactId}"/> 
    ... 
</entry>