我无法从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);
})
在Content类型中,我尝试了JSON和XML。还在上面的URL中添加了access_token。所以请帮我拍这张照片。
提前谢谢。
答案 0 :(得分:0)
请参阅Retrieving a contact's photo:
要检索联系人的照片,请向联系人的照片链接网址发送授权的GET请求。
网址格式为:
https://www.google.com/m8/feeds/photos/media/{userEmail}/{contactId}
使用适当的值代替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>