2014-02-11 58 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