gpt4 book ai didi

django - 从 google plus 获取个人资料图片

转载 作者:太空宇宙 更新时间:2023-11-03 15:25:18 25 4
gpt4 key购买 nike

我已经将 google app engine 与 django 应用程序一起使用。我一直在使用 google 的用户 api 登录我的网站,并从中获取当前用户的电子邮件地址,但我必须获取在 google plus 帐户上上传的个人资料图片。

我正在使用他们的头像,

<img src="https://plus.google.com/s2/photos/profile/<user_id>?sz=100" width="100" height="100">

在谷歌 API 中。

用户类还提供了 user_id 但我无法使用该 user_id 获取他们的头像。

Google API 用户类的 user_id 不同。

如何在我的应用程序中获取头像?

最佳答案

方法是在这里使用 google+ api:https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=me&_h=2&

这是为当前经过身份验证的用户拉取图像的请求。

GET https://www.googleapis.com/plus/v1/people/me?key={YOUR_API_KEY}

你会得到一个像这样的 json 响应,解析它并提取 image->url 值来显示真的很容易。

{
"kind": "plus#person",
"etag": "\"XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXx\"",
"gender": "male",
"emails": [
{
"value": "jbrahy@XxXxXxXx.com",
"type": "account"
}
],
"objectType": "person",
"id": "XxXxXxXxXxXxXxXxXxXxXxXx",
"displayName": "John Brahy",
"name": {
"familyName": "Brahy",
"givenName": "John"
},
"url": "https://plus.google.com/XxXxXxXxXxXxXxXxXxXxXxXx",
"image": {
"url": "https://lh3.googleusercontent.com/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/photo.jpg?sz=50"
},
"isPlusUser": true,
"language": "en",
"circledByCount": 2,
"verified": false,
"cover": {
"layout": "banner",
"coverPhoto": {
"url": "https://lh5.googleusercontent.com/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/Green%2BGrass.jpg",
"height": 240,
"width": 420
},
"coverInfo": {
"topImageOffset": 0,
"leftImageOffset": 0
}
},
"domain": "XxXxXxXx-x.com"
}

关于django - 从 google plus 获取个人资料图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21779035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com