如何通过 Google plus 中的用户 ID 获取用户图像? [英] How to get user image through user id in Google plus?

查看:27
本文介绍了如何通过 Google plus 中的用户 ID 获取用户图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经通过这个 URL 获取用户图片

新技巧

获取请求:

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

响应:200 OK

<代码>{图片":{"url": "https://lh3.googleusercontent.com/-OkM...AANA/ltpH4BFZ2as/photo.jpg?sz=50"}}

其中 YOUR_API_KEY 是您的 公共 API 访问密钥,它是通过 API 和 API 下的凭据生成的.从 https://console.developers.google.com/

进行身份验证

并且在创建公共 API 访问密钥时,您可以选择应该发出此请求的引荐来源 URL,但为了进行检查,您应该尝试不向其中添加任何 URL,如果有效,请使用您网站的网址.

您可以从此处选择其他字段以发送您可能需要的网址.

快乐编码!!!

I used to get user image through this URL

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

but now what all I am getting is 404 error or no image. I know google has changed its policies and way it connects and allows other to get information, but I didn't anything to achieve same result as above.

Note: I can't use authenticate thing here since I am showing image of users to other users which are not connected at all.

OR in other way user may be not coming from Google log-in but I need to show other Google users images only.

Any help would be highly appreciated!!!

Edit: I have checked through people.get method

https://www.googleapis.com/plus/v1/people/11595...3592320?key=AIzaSyCkdmtNN1XDg....EpepOIIs

but I am getting error saying

{
   "error": {
     "errors": [
        {
          "domain": "usageLimits",
          "reason": "accessNotConfigured",
          "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
        }
     ],
   "code": 403,
   "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
  }
}

Edit: I have this already enabled since I am using Google+ log-in already in my site, here I am attaching screenshot:

解决方案

Earlier I have also the same problem for my site after so much of research and efforts I found solution from my self and i hope that will also work for you and solve your problem:

Old Trick

Google had changed their policy so the old trick for getting the Google profile image will not work now.

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

New Trick

Get Request:

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

Response :200 OK

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

Where YOUR_API_KEY is your Public API Access key which is generated through Credentials under APIs & Auth from https://console.developers.google.com/

And While creating Public API access key you can choose Referers URL's from which this request should be made but for checking you should try by not adding any URL to it, if it works then go with URL of your site.

You can choose other fields to send with URL which you may need from here.

Happy Coding!!!

这篇关于如何通过 Google plus 中的用户 ID 获取用户图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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