方法是在这里使用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"
}