[英]JS how to get photo from api and using FileReader() add it to localStorage?
[英]How to get a photo from Google Contacts API using 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);
})
在Content類型中,我嘗試了JSON和XML。 還在上面的URL中添加了access_token。 因此,請幫助我獲取此圖像。
先感謝您。
請參閱檢索聯系人的照片 :
要檢索聯系人的照片,請將授權的GET請求發送到聯系人的照片鏈接URL。
URL的格式為:
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.