![](/img/trans.png)
[英]How to get Facebook user's friends' profile picture using Javascript SDK V2.0
[英]How to get Facebook user's friends information using JavaScript SDK
我正在使用Facebook JavaScript SDK。 我可以使用以下方式获取用户的信息:
FB.api('/me', function(response) {
....
});
我得到用户的朋友使用:
FB.api('/me/friends', function(response) {
...
}); //.. it only has two values name and id.
我想得到朋友出生日期和地点。 是否有FB.api
方法来获取它,或者我可以使用FB.Data.query获取它吗?
这样做:
FB.api('/me/friends', function(response) {
...
}); //.. it only has two values name and id.
你会得到:
{data: [{id: "xxxxx", name: "Friend name"}, {id: "xxxxx", name: "Friend name"}]}
您可以使用收到的ID访问资源:
FB.api('/xxxxx', function(response) {
...
}); // {first_name: "Name", gender: "male", id: "xxxxxx",.. etc}
您需要具有user_birthday
, friends_birthday
, user_location
和friends_location
权限的经过身份验证的用户 。 然后你可以这样做:
FB.api('/me/friends', { fields: 'name,id,location,birthday' }, function(result) {
// resut has the data
})
在这里尝试一下 。
我对FB API几乎一无所知,但你看过这个: http : //developers.facebook.com/docs/reference/javascript/FB.Data.query
还有这个:
http://developers.facebook.com/docs/reference/fql/
您可以使用FB.api在数组中获取完整朋友的id和名称。 需要使用FB.init初始化应用程序,然后检查用户是否使用FB.getloginstatus()登录。 那么只有FB.api才有用。
这是一个链接 ,解释了如何使用Javascript SDK获取朋友。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.