Facebook - 得到朋友的朋友 [英] Facebook - get friends of friends

查看:103
本文介绍了Facebook - 得到朋友的朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用登录用户的脚本 - 检索朋友列表并循环访问这些朋友以获取他们的朋友列表。意思是用户的朋友的朋友。我读过某个地方这是不可能的,但是如果我用我的用户登录facebook.com并浏览我的一个朋友,我可以很容易地看到他的朋友列表?你可以帮助澄清吗?

I'm trying to do a script which takes the logged-in user - retrieves the list of friends and loops through these friends to get their friendlist. Meaning the users friends-of-friends. I've read somewhere that this isn't possible, but if I log in to facebook.com with my user and browse one of my friends, I can easily see his friendlist? Can you help clarifying this?

我的代码:

    $friends = $facebook->api('/me/friends');

foreach ($friends["data"] as $friend) {

    try {
        $friendsfriends = $facebook->api('/'.$friend["id"].'/friends?fields=name,hometown,location,picture');
    } catch(Exception $e) {
        $friendsfriends = null;
    }

    print '<pre>';
    print var_dump($friendsfriends);
    print '</pre>';
}

哪些错误表示我无法查看用户的朋友。 p>

Which casts some error saying I can't view the users friends.

推荐答案

你所要做的是不可能的。当用户授权并正在使用您的应用程序时,该组扩展权限(请参阅 Facebook权限)明确地应用于该用户。因此,如果您有扩展权限来阅读朋友数据,则只能获取相对于当前用户的朋友数据,因为这些权限是您拥有的权限,而对于朋友,您没有有效的访问令牌进一步。如果您想通过图表进一步浏览,那么这些朋友必须已经授权您的应用程序,您将需要离线访问令牌才能获取他们的朋友数据。

What you are looking to do is not possible. When a user has authorised and is using your application, the set of extended permissions (see Facebook Permissions) apply explicitly to that user. So if you've got extended permissions to read friend data, you can only get friend data relative to the current user - because those are the permissions you have and you don't have valid access tokens, with respect to the friends, to go further. If you wanted to traverse further through the graph, those friends would have to have authorised your application and you would require an offline access token to get to their friend data.

是在Facebook的主要网站上提供的一些功能,不能通过任何Facebook API。这可能是令人沮丧的,但是您必须做出可用的功能。

There are a number of capabilities available on the main Facebook site that are not available via any the Facebook API. This can be frustrating, but you have to make do with the capabilities that are available.

这篇关于Facebook - 得到朋友的朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆