我正在使用google aouth跟随范围
scope : ['https://www.googleapis.com/auth/tasks', 'https://www.googleapis.com/auth/tasks.readonly', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/plus.circles.read']
我试图获取有关用户的信息,我使用了以下API
var xhr = Ti.Network.createHTTPClient({
onload : function() {
var data = this.responseText;
var json = JSON.parse(data);
Ti.API.log('json: ' + JSON.stringify(json));
}
});
xhr.open("GET", "https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=" + googleAuth.getAccessToken());
xhr.send();
但它只提供有关用户基本信息的信息,如何获取有关圈内用户朋友的信息。
我用
替换了xhr.open("GET", "https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=" + googleAuth.getAccessToken());
xhr.open("GET", "https://www.googleapis.com/plusDomains/v1/people/me/circles?access_token=" + googleAuth.getAccessToken());
控制台中的响应文本就像
json: {"error":{"errors":[{"domain":"global","reason":"forbidden","message":"Forbidden"}],"code":403,"message":"Forbidden"}}
我启用了
答案 0 :(得分:1)
最接近API的是People.list
https://www.googleapis.com/plus/v1/people/me/people/connected?key={YOUR_API_KEY}
尝试测试集合,看看哪一个更符合您的需求。您可以在页面底部测试结果。没有办法得到圆圈的名称。
可接受的值是:
“connected”:经过身份验证的用户中的可见人员列表 也使用请求应用的圈子。此列表仅限用户 谁使他们的应用程序活动对经过身份验证的用户可见。
“visible”:此用户添加到一个或多个人的人员列表 圆圈,仅限于请求应用程序可见的圆圈。
答案 1 :(得分:0)
截至2018年8月,Google + API端点https://www.googleapis.com/plus/v1/people/userId/people/collection
is deprecated。
There is a new endpoint用于获取所有联系人:https://people.googleapis.com/v1/people/me/connections
。
响应中有一个metadata
键,对于Google+联系人,它看起来会像这样:
"metadata": {
"sources": [
{
"updateTime": "2013-01-13T19:16:50.668Z",
"etag": "...",
"type": "CONTACT",
"id": "..."
},
{
"etag": "...",
"type": "PROFILE",
"id": "...",
"profileMetadata": {
"userTypes": [
"GOOGLE_USER",
"GPLUS_USER"
],
"objectType": "PERSON"
}
}
],
"objectType": "PERSON"
}
请注意"GPLUS_USER"
部分。