Nic*_*ick 7 javascript facebook
我正在使用Facebook JavaScript SDK.我可以使用以下方式获取用户的信息:
FB.api('/me', function(response) {
....
});
Run Code Online (Sandbox Code Playgroud)
我得到用户的朋友使用:
FB.api('/me/friends', function(response) {
...
}); //.. it only has two values name and id.
Run Code Online (Sandbox Code Playgroud)
我想得到朋友出生日期和地点.是否有FB.api方法来获取它或我可以使用FB.Data.query获取它?
首先您的应用需要有正确的权限,friends_birthday而friends_location在这种情况下.
接下来,使用fieldsGraph API请求中的参数来请求birthday和location字段:
FB.api('/me/friends', {fields: 'name,id,location,birthday'}, function(response) {
//...
});
Run Code Online (Sandbox Code Playgroud)
根据某些朋友帐户的隐私设置,您可能会或可能无法访问生日或位置数据,因此请务必处理缺少信息的情况.看到这个问题的原因.
小智 5
这样做:
FB.api('/me/friends', function(response) {
...
}); //.. it only has two values name and id.
Run Code Online (Sandbox Code Playgroud)
你会得到:
{data: [{id: "xxxxx", name: "Friend name"}, {id: "xxxxx", name: "Friend name"}]}
Run Code Online (Sandbox Code Playgroud)
您可以使用收到的ID访问资源:
FB.api('/xxxxx', function(response) {
...
}); // {first_name: "Name", gender: "male", id: "xxxxxx",.. etc}
Run Code Online (Sandbox Code Playgroud)
我对 FB API 几乎一无所知,但你看过这个吗:
http: //developers.facebook.com/docs/reference/javascript/FB.Data.query
还有这个:
http://developers.facebook.com/docs/参考/fql/
| 归档时间: |
|
| 查看次数: |
37489 次 |
| 最近记录: |