使用 Graph API 获取我朋友的朋友
我正在尝试使用新的 Graph API 做一件非常基本的事情。
我已经知道如何联系我的朋友了: “https://graph.facebook.com/me/friends?access_token=4333ed34d...”
但是如果我有一个 ID 为 123456 的朋友,那么我想获取他的朋友: “https://graph.facebook.com/123456/friends?access_token=4333ed34d...”
但我得到一个例外:
“远程服务器返回错误:(500) 内部服务器错误。”
为什么我不能这样做?从 API 请求是一项非常简单的任务。
I am trying to do a very basic thing with the new Graph API.
I already know how to get my friends:
"https://graph.facebook.com/me/friends?access_token=4333ed34d..."
But if I have a friend who's ID is 123456, then I want to get his friends :
"https://graph.facebook.com/123456/friends?access_token=4333ed34d..."
But I get an exception:
"The remote server returned an error: (500) Internal Server Error."
Why can't I do that? It's a very trivial task to ask from the API.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果我尝试获取随机用户的朋友,我会得到 HTTP 500,但它包含以下响应:
这是非常不言自明的。
如果我尝试让我朋友的朋友允许查看他的其他朋友,效果很好。如果我的朋友选择不允许查看他的其他朋友,我会得到同样的错误。
If I try to get friends of a random user I get HTTP 500 but it contains this response:
which is pretty self-explanatory.
If I try to get friends of my friend who allows viewing his other friends it works fine. If my friend chose to not allow viewing his other friends I get the same error.
你实际上可以从公共脸书上窃取信息。它并不漂亮,需要几秒钟,但可以工作。
我有一个从控制台运行并发出 AJAX 请求的 JS 代码 - 当您向下滚动时,在常规 facebook UI 中请求更多好友时,facebook 也会发出相同的请求(http://www.facebook.com/profile.php?sk=friends) 。然后我解析结果。到目前为止,它运行完美。我只是要求有更多的朋友,当我没有找到匹配的人时,我知道我已经拥有了他们。
我不想共享整个代码,但这是重要的部分:
您可以从当前登录的用户处获取必要的变量,如下所示:
我知道这对您的情况可能没有用,因为这是 JS。无论如何,有人可能会发现这很有用。
PS: $jq = jQuery.
PPS:这些作业对象负责处理连续的 ajax 请求。我发现我需要它们,因为我的 FF 不想同时发出 2000+ AJAX 请求:-D
you can actualy steal the information from public facebook. It's not pretty, takes a couple seconds, but works.
I have a JS code that runs from console and makes AJAX request - the same facebooks makes when requesting more friends in the regular facebook UI when you scroll down (http://www.facebook.com/profile.php?sk=friends). Then I parse the result. So far it works flawlessly. I just ask for more friends and when I don't get a match, I know I have them all.
I don't want to share the whole code, but this is the essential part:
You can get the neccesary variables from a currently logged in user like this:
I understand this is probably useless for your case since this is JS. Anyway, someone might find this usefull.
P.S.: $jq = jQuery.
P.P.S.: those job objects take care of sequential ajax requests. I found out I need them since my FF didn't feel like making 2000+ AJAX request at the same time :-D
你就是不能那样做。
如果您在用户授权您的应用程序时需要适当的扩展权限,您可以访问当前登录用户的朋友的一些数据,但这就是您获得的全部(http://developers.facebook.com/docs/authentication/permissions 请参阅:friends_xxxx 权限),但不是他/她的朋友。
You just can't do that.
If you require the appropriate extended permission when the users authorize your app, you can access some data of the currently logged user's friends, but that's all you get (http://developers.facebook.com/docs/authentication/permissions see: friends_xxxx permissions), but not his/her friends.
我有朋友的朋友(有限)。我有同样的问题。虽然回答问题已经很晚了,但它会对某人有所帮助。这就是为什么回答这个问题。
我们可以找到应用程序用户的朋友的朋友。
它需要以下要求:
$fb_id= 朋友的朋友需要的用户ID。
尝试这个 fql 查询。
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.
It needs following requirements:
$fb_id= user id whose friends of friends required.
Try this fql query.