在 FB 图 API 中获取朋友的朋友
我想通过 API 调用联系朋友的朋友,当我尝试这样做时,出现以下异常,
{
"error": {
"type": "OAuthException",
"message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"
}
}
我尝试访问的 URL 是,
https://graph.facebook.com/friend_id/朋友?access_token=access_token
我正在获得扩展权限,如下所示,
<fb:login-button perms="user_likes,friends_likes"></fb:login-button>
有人可以让我知道这里出了什么问题吗?或者这是否意味着我永远无法联系朋友的朋友?
I would like to get friends of friends via an API call and when I try to do it, I get the following exception,
{
"error": {
"type": "OAuthException",
"message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"
}
}
The URL I am trying to access is,
https://graph.facebook.com/friend_id/friends?access_token=access_token
I am getting extended permissions which is as follows,
<fb:login-button perms="user_likes,friends_likes"></fb:login-button>
Could any one please let me know what's going wrong here? Or does it mean I can never get access to friends of friends?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以通过对我/朋友的 Graph API 调用来获取当前用户的朋友。您将需要任何有效的 access_token,不需要特殊的扩展权限,只需基本权限。有一个警告,该用户必须允许您查看他们的朋友列表。所以在隐私设置>在 Facebook 上连接有一个“查看你的朋友列表”设置。如果用户选择了自定义设置并选择了“仅我”,您将收到此错误。
同样,如果当前用户允许其他人查看他们的朋友列表,但其中一位朋友出于隐私问题而将其关闭,那么您将无法看到任何数据并会收到该错误。
我能够验证我所描述的场景。
You can get the friends of the current user through a Graph API call to me/friends. You will need any valid access_token, no special extended permissions, just the Basic one. There is one caveat, that user must allow you to see their friend list. So in the Privacy Settings > Connecting on Facebook there is a "See your friend list" setting. If the user has chosen a custom setting and selected say "Only Me" you will get this error.
Similarly, if the current user allows others to see their friend list, but one of the friends shuts this down due to privacy concerns then you will not be able to see any data and will get that error.
I was able to verify the scenarios I have described.
不幸的是,我不能具体询问你的答案,因为我没有 FB API 的经验。然而,我相信FB允许用户隐藏他们的朋友是谁。如果他们有这套,那么也许您根本无法访问他们的朋友。我会尝试修改您的代码,首先检查给定用户的权限是什么,然后只有在您有权访问时才访问他们的朋友列表。不过,这里有一些猜测。
Unfortunately, I can't ask your answer specifically since I don't have experience with the FB API. However, I believe that FB allows users to hide who their friends are. If they have this set, then perhaps you won't be able to access their friends at all. I'd try to modify your code to first check what the permissions of a given user are and only then accessing their friends list if you have access to it. A bit of speculation here, though.
目前,没有扩展权限允许您查看用户朋友的朋友。 “*_likes”权限仅显示用户喜欢的 Facebook 页面。
您可能可以一一迭代地获取和缓存每个用户朋友的朋友,但如果没有每个朋友的访问令牌,您将只能获取公共数据。
Currently, there is no extended permission that allows you to view a user's friends of friends. The "*_likes" permissions just show you the Facebook pages that the users have Liked.
It might be possible for you to iteratively fetch and cache the friends of each of the user's friends, one by one, but without access tokens for each friend, you'll only be able to fetch public data.
我有朋友的朋友(有限)。我有同样的问题。虽然回答问题已经很晚了,但它会对某人有所帮助。这就是为什么回答这个问题。
我们可以找到应用程序用户的朋友的朋友。
$fb_id= 朋友的朋友需要的用户ID。
@Olie:
您正在通过应用程序获取您朋友的朋友。因此,您需要获得您想要的朋友的许可。即您的朋友应该使用该应用程序并接受这些许可,同时允许访问信息。否则你将无法成为你朋友的朋友。我已经测试过这个查询。并且它运行成功。
这条消息很好地解释了。仔细阅读。
希望您了解解决方案标准。
I got friends of friends(limited). I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
We can get friends of friends those are app users.
$fb_id= user id whose friends of friends required.
@Olie:
You are fetching your friends of your friend through application. So you would need permission from your friend whose friends you want. i.e. Your friend should be using that application and accepted those permission while allowing accessing information. Otherwise you wont be able to friends of your friend. I have tested this query. And it works successfully.
This message explains well. Read carefully.
Hope you understand solution criteria.
您无法找到朋友的朋友,出于隐私考虑,这是不允许的。
我们之前做过的一个解决方法是将所有用户朋友保存到我们自己的数据库中。
这样我们就可以交叉引用所有不同用户的朋友列表,并至少获得使用过我们制作的应用程序的朋友的朋友。
重要提示,根据您获得的用户数量,这样的表很快就会变得相当可抢占。
预计每个用户平均大约有 250-300 个朋友,因此,如果您选择这样的解决方案,请确保针对它优化您的数据库,然后它应该会很好地工作。
You cannot get friends of friends, it is not allowed due to privacy concerns.
A workaround we have done before is to save all users friends to oure own database.
That way we could cross-reference all the different users friend-list's and at least get friends of friends who have used the application we made.
Important note, such a table would quickly grow quite seizable depending on the amount of users you get.
Count on each user having about 250-300 friends on average, so if you opt for such a solution make sure to optimize your database for it, and then it should work just great.
遇到同样的问题,必须使用旧的 REST API 才能至少获得共同的朋友,请参阅
http://developers.facebook.com/docs/reference/rest/friends。获取共同好友/
Got same problem, had to use old REST API to get at least mutual friends, see
http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends/