从电子邮件地址获取用户Google帐户图片

时间:2013-12-02 10:00:43

标签: android gmail

我有来自日历的用户的电子邮件ID列表,如

{
  "kind": "calendar#event",
  "etag": "\"zDYNyduc5vEaXlXz7scQOpE_a8Y/MTM3MjA4MTk2MjYwNDAwMA\"",
  "id": "9r48ao9snfaotnao2r82kpjvh4",
  "status": "confirmed",
  "htmlLink": "https://www.google.com/calendar/event?eid=OXI0OGFvOXNuZmFvdG5hbzJyODJrcGp2aDQgMXJzMGZlYXNsaXY4Z3VkNTE5aGlybXVvamdAZw",
  "created": "2013-06-24T13:52:42.000Z",
  "updated": "2013-06-24T13:52:42.604Z",
  "summary": "Arsenal v Southampton",
  "location": " \tEmirates Stadium",
  "creator": {
    "email": "premiercalendar@gmail.com",
    "displayName": "Premier League"
  },
  "organizer": {
    "email": "1rs0feasliv8gud519hirmuojg@group.calendar.google.com",
    "displayName": "Premier League",
    "self": true
  },
  "start": {
    "dateTime": "2013-11-23T16:00:00+01:00"
  },
  "end": {
    "dateTime": "2013-11-23T17:45:00+01:00"
  },
  "iCalUID": "9r48ao9snfaotnao2r82kpjvh4@google.com",
  "sequence": 0
},

这里我有creator email address,我的日历上的每个事件都有很多这样的记录

现在,我需要从premiercalendar@gmail.com

等电子邮件地址中获取用户图片

更新:是否可以在没有oauth身份验证的情况下获取此内容?

更新2:我发现对于facebook我可以获得以下网址的用户图片

https://graph.facebook.com/search?q=email@example.com&type=user

但与访问令牌一起 g +

的任何类似方法

关于如何实现这一目标的任何想法?

提前致谢

2 个答案:

答案 0 :(得分:1)

您可以从XML链接获取用户公开详细信息...

https://gdata.youtube.com/feeds/api/users/<paste_google_username>

你可以很容易地得到它......

    int start = xml.indexOf("<media:thumbnail url='");
    String urlPart = xml.substring(start);
    thumbnail_url = (String) urlPart
                                .subSequence(urlPart.indexOf("http"),
                                        urlPart.indexOf("'/>"));
    Log.d("picture321", thumbnail_url);

    HttpGet httpRequest = new HttpGet(URI.create(thumbnail_url));
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = null;

    try {
        response = (HttpResponse) httpclient.execute(httpRequest);
        HttpEntity entity = response.getEntity();
        BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
        Bitmap bm = BitmapFactory.decodeStream(bufHttpEntity.getContent());
        httpRequest.abort();


        } 
       catch (ClientProtocolException el) {
        // TODO Auto-generated catch block
        el.printStackTrace();
        } 
       catch (IOException el) {
        // TODO Auto-generated catch block
        el.printStackTrace();
        }

答案 1 :(得分:0)

我认为不可能通过电子邮件获取某个人的详细信息,但使用Google OAuth,您可以收到电子邮件以及此人的所有其他详细信息。

见这里:https://developers.google.com/+/web/people/