2017-09-21 15 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

ステータスが404であることからGoogleから応答がありました。イメージのバイトはありません。 –

答えて

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> 
関連する問題