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

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

问题描述

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



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



现在Google Plus有这个功能吗?或者任何其他方式来获取用户的图片,而无需API调用?

解决方案

Google已经改变了他们的政策, Google个人资料图片现在无法使用,这是

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





请求URL

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

这将给出如下所示的json格式的Google个人资料图片url



回复: p>

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




更多参数可以找到通过此处可能需要的网址发送



有关更多详细信息,还可以检查给出的问题,我已经为相同类型的问题回答了问题


<快乐编码!!


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

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

解决方案

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

New Way for doing this is

Request URL

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

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

Response :

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


More parameters can be found to send with URL which you may need from here

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?

Happy Coding!!

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

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