How to fetch email addresses of Google plus circles (Friends added in Google plus circles)

╄→尐↘猪︶ㄣ 提交于 2019-12-06 02:57:50

问题


I am able to login with google plus and have fetch the list of all the people who are in my google plus circle but now i also want to get the email addresses of all people in my circle is there are way to do it? I have tried this code but it does not work.

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(); 
            }
}

回答1:


You would probably need to request both the Google+ scopes and the Contacts API scope (https://www.google.com/m8/feeds). You would then need to request the user's contacts and find those with Google+ profile URLs, which will look something like:

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

Then you'd look to see if an email address also existed for that contact as a sibling element.



来源:https://stackoverflow.com/questions/19114453/how-to-fetch-email-addresses-of-google-plus-circles-friends-added-in-google-plu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!