2014-02-11 54 views
2

您好我已經通過Javascript方法(Javascript)完成了Google Contacts V3 API的實現。像下面snipet:我需要Google Plus配置文件ID以及google contacts v3 API

//The google login url 
https://www.googleapis.com/plus/v1/people/me 
access_token='dsfjkasdkfjgasdf'; 


$.get("https://www.google.com/m8/feeds/contacts/default/full?access_token="+access_token+"&alt=json",{},function(xmldata) { 
//console.log(xmldata.feed.entry); 

var contacts =[]; 
$.each(xmldata.feed.entry,function(i,tag) { 
    var contact_id=tag.id.$t; 
    var name = tag.title.$t; 
    var contact_emails = tag.gd$email; $.each(contact_emails,function(key,val){ social_email=val.address; }); 

    contacts.push({id:contact_id,name:name,email:social_email}); 

    console.log("id="+id+" name="+name+" email="+social_email+"\n"); 

    // store social contacts to db 
}); 

},"json").fail(fail); 

和全成響應:

{ 
"id": { 
    "$t": "http://www.google.com/m8/feeds/contacts/{email}/base/{contact_id}" 
}, 
"updated": { 
    "$t": "2013-01-10T05:16:03.705Z" 
}, 
"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/{email}/{contact_id}/9sadsdkj90" 
    }, 
    { 
     "rel": "self", 
     "type": "application/atom+xml", 
     "href": "https://www.google.com/m8/feeds/contacts/{email}/full/{contact_id}" 
    }, 
    { 
     "rel": "edit", 
     "type": "application/atom+xml", 
     "href": "https://www.google.com/m8/feeds/contacts/{email}/full/{contact_id}/1357794963705ffdd1" 
    } 
], 
"gd$email": [ 
    { 
     "rel": "http://schemas.google.com/g/2005#other", 
     "address": "[email protected]", 
     "primary": "true" 
    } 
] 
} 

響應也返回用戶聯繫信息,但我需要谷歌,加上ID(即配置文件ID)。

請提示我如何從聯繫人詳細信息(姓名,電子郵件等)獲取gid(Google+ id)?請幫助獲取所有聯繫人的個人資料ID ...

+2

我可以知道爲什麼投票嗎?你可以評論任何疑慮?我知道我的英語不符合標準......! – ShivarajRH

+0

我想存儲GID(個人資料ID)以及詳細的聯繫方式... – ShivarajRH

回答

2

對於您的已認證用戶,用戶的Google+ ID與OAuth 2.0 ID相同,可通過傳入訪問令牌從API call to the oauth2.tokeninfo endpoint中檢索。

從tokeninfo的響應將包含以下內容:

{ 
"issued_to": "yourclientid.apps.googleusercontent.com", 
"audience": "yourclientid.apps.googleusercontent.com", 
"user_id": "{auth user's id}", 
"scope": "" 
"expires_in": 3584, 
"access_type": "online" 
} 

現在,你也可以嘗試做的是找回了Google+ IDS用於連接到特定的用戶們。這是通過聯繫人API無法做到的,但可以通過將用戶在您的應用中看到的人員列入他們的Google+圈子來完成。

該API有plus.people.list

+1

是的你是對的...我錯了,並試圖通過聯繫人API聯繫人信息。但後來我瞭解了plus.people.list Google Plus API的使用情況,以列出所有關聯的人的信息。現在,隨着用戶登錄,人員列表請求將確認用戶獲取人員列表。所有工作正常。無論如何感謝您的回答。 – ShivarajRH

+0

@ShivarajRH您是如何將Google plus id與contat詳細信息(名稱,電子郵件等)進行映射的? – vimal1083