2013-10-01 124 views
5

我可以使用Google plus登錄並獲取所有在我的谷歌加圈中的所有人的列表,但現在我也想要獲取我圈子中所有人的電子郵件地址是否有辦法做到這一點?我試過這段代碼,但它不起作用。如何獲取Google plus圈子的電子郵件地址(在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

http://stackoverflow.com/a/15385160/1292203看看它 –

+0

我已經收到登錄的人的電子郵件地址,我想要取回他的電子郵件地址(登錄的人)朋友。所以我可以發送電子郵件/邀請來使用我的應用程序 –

+0

@NoumanBhatti:你有沒有得到解決方案? – TheDevMan

回答

1

你可能需要請求既Google+的範圍和Contacts API範圍(https://www.google.com/m8/feeds)。然後,您將需要請求用戶的聯繫人,找到那些Google+ profile URLs,這將是這個樣子:

<gContact:website href='http://www.google.com/profiles/1234567890' rel='profile'/> 

然後,你看看,如果電子郵件地址也存在該聯繫人作爲同級元素。

+0

感謝您的答覆。但我不明白。你能否再詳述一下你的答案? –

相關問題