jqueryを使用してGoogleの連絡先を取得する必要があります。そして、私は完全に実装することに成功しました。しかし、問題は、その連絡先の名前を取得できないことです。Google は、そのユーザーのメール アドレスを提供しているだけです。ユーザーが他の情報を提供することはありません。だから私は何かが恋しいです。
ここで、応答付きの完全なコードを添付します。
ここに完全なコードがあります
<script type="text/javascript" src="https://apis.google.com/js/client.js"></script>
<script type="text/javascript">
var clientId = "google_clientId";
var apiKey = "google_api_key";
var scopes = 'https://www.google.com/m8/feeds/';
$(document).on("click", ".googleContactsButton", function (e) {
gapi.client.setApiKey(apiKey);
window.setTimeout(authorize);
});
function authorize() {
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthorization);
}
function handleAuthorization(authorizationResult) {
if (authorizationResult && !authorizationResult.error) {
$.get("https://www.google.com/m8/feeds/contacts/default/full?alt=json&access_token=" + authorizationResult.access_token + "&alt=json",
function (response) {
//process the response here
console.log(JSON.stringify(response));
});
}
}
</script>
これがAPIの応答です
[
{
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/ishan%40inheritx.com/base/87427988f9359bf"
},
"updated": {
"$t": "2016-07-21T08:09:55.053Z"
},
"category": [
{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}
],
"title": {
"type": "text",
"$t": ""
},
"link": [
{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/ishan%40inheritx.com/87427988f9359bf/1B2M2Y8AsgTpgAmY7PhCfg"
},
{
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/ishan%40inheritx.com/full/87427988f9359bf"
},
{
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/ishan%40inheritx.com/full/87427988f9359bf/1469088595053001"
}
],
"gd$email": [
{
"rel": "http://schemas.google.com/g/2005#other",
"address": "prakash@inheritx.com"
}
]
}
]
それに応じて、名と姓のようなフィールドは見つかりませんでした。助けていただければ幸いです。
しかし、名前を手動で追加すると、タイトル キーに表示されます。しかし、その連絡先名が google+ から同期されている場合、空白が表示されます。
ありがとう