使用 user_id 获取 Google+ 个人资料图片网址 [英] Getting Google+ profile picture url with user_id

查看:23
本文介绍了使用 user_id 获取 Google+ 个人资料图片网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道很多社交网络 API 都提供了一种方法,可以使用用户的 user_id 或用户名来构建指向用户个人资料图片的 url.对于 Facebook,它看起来像这样:

I know that lots of social network APIs provide a way to construct a url to the profile picture of a user, using their user_id or username. For Facebook it looks like this:

http://graph.facebook.com/user_id/picture?type=square

Google Plus 现在有这样的功能吗?或者任何其他无需 API 调用即可获取用户图片的方法??

Now is there something like this for Google Plus? Or any other way to get user's pic without an API call??

推荐答案

Google 已经更改了他们的政策,因此获取 Google 个人资料图片的旧方法现在不再适用了,这是

Google had changed their policy so the old way for getting the Google profile image will not work now, which was

https://plus.google.com/s2/photos/profile/(user_id)?sz=150

这样做的新方法是

请求网址

https://www.googleapis.com/plus/v1/people/115950284...320?fields=image&key={YOUR_API_KEY}

这将以 json 格式提供 Google 个人资料图片网址,如下所示

That will give the Google profile image url in json format as given below

回复:

{
    "image": 
    {
         "url": "https://lh3.googleusercontent.com/-OkM...AANA/ltpH4BFZ2as/photo.jpg?sz=50"
    }
}

可以从这里找到更多参数,您可能需要使用 URL 发送

有关更多详细信息,您还可以查看给定的问题,其中我已经回答了相同类型的问题如何通过用户id获取用户图片在 Google plus 中?

For more detail you can also check the given question where I have answered for same type of problem How to get user image through user id in Google plus?

这篇关于使用 user_id 获取 Google+ 个人资料图片网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆