我可以使用google plus登录并获取我谷歌加圈子中所有人的列表但现在我还想获取我圈子中所有人的电子邮件地址是否有办法实现?我已经尝试过这段代码,但它不起作用。
public void onPeopleLoaded(ConnectionResult status, final PersonBuffer personBuffer,
String nextPageToken)
{
if (status.getErrorCode() == ConnectionResult.SUCCESS)
{
try
{
//Add all friends ids in an arraylist
int count = personBuffer.getCount();
//Loop through all the ids of google plus friends
for (int i = 0; i < count; i++)
{
//mListItems.add(personBuffer.get(i).getDisplayName());
//mListIds.add(personBuffer.get(i).getId());
friends_gplus_Ids += personBuffer.get(i).getId() + ",";
//Log.d("Emails", personBuffer.get(i).getOrganizations().toString());
//personBuffer.get(i).getEmails().size();
if((personBuffer.get(i).getEmails().size() > 0))
{
Log.d("Emails", personBuffer.get(i).getEmails().get(0).toString());
}
else
{
Log.d("Emails", "Null");
}
}
}
finally
{
personBuffer.close();
}
}
答案 0 :(得分:1)
您可能需要同时申请Google+范围和Contacts API范围(https://www.google.com/m8/feeds
)。然后,您需要请求用户的联系人并找到Google+ profile URLs的联系人,其类似于:
<gContact:website href='http://www.google.com/profiles/1234567890' rel='profile'/>
然后你会看看该联系人是否也存在一个电子邮件地址作为兄弟元素。