FQL:获得共同的好友,从而减少查询次数

发布于 2024-10-11 00:27:07 字数 1142 浏览 0 评论 0原文

我正在制作一个社交应用程序,它从 Facebook 获取数据并以一种奇特的方式显示它,该应用程序首先抓取 10 个随机朋友,然后(尝试)抓取登录用户和这 10 个朋友中每一个朋友之间的共同朋友。

使用 FQL 获取 10 个朋友非常容易,但是在应用程序不进行 2000 个 API 调用的情况下寻找共同的朋友时我遇到了很大的问题!

这样它就可以工作了

function GetMutualFriendsFor($id)
    {
        // Queries and returns results for mutual friends between user and id
        $param  =   array(
                            'method'  => 'friends.getMutualFriends',
                            'source_uid'    => $this->_user['id'],
                            'target_uid'  => $id,
                            'callback'=> ''
                        );
        $mutualFriends = $this->_instance->api($param);

    }

,不幸的是,运行这个函数一次大约需要 3 分钟。将其乘以 10 倍,你就可以在启动脚本后开始做午餐了!

我正在考虑使用 FQL 来执行此操作,因为它更快,并且返回的数据量正是我想要的(uid,名称)我已经尝试过

    $query = 'SELECT uid1 FROM friend WHERE uid2=me() AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=' . $id .') LIMIT 5';

但是 PHP 抛出错误:无法查找 1523223065 的所有朋友。只能查找登录用户(665044728),或具有适当权限的登录用户的朋友

有人知道该怎么做吗? PS:我已经看过 stackoverflow 上关于此的所有其他帖子,不幸的是没有任何成功:(

非常感谢!!

I am making a social app which obtains data from Facebook and displays it in a fancy way, the app first grabs 10 random friends and then (tries) to grab the mutual friends between the logged in user and each of the 10 friends.

Obtaining the 10 friends has been incredibly easy using FQL, but I have major problems finding the mutual friends without the application making 2000 API calls!

This way it works

function GetMutualFriendsFor($id)
    {
        // Queries and returns results for mutual friends between user and id
        $param  =   array(
                            'method'  => 'friends.getMutualFriends',
                            'source_uid'    => $this->_user['id'],
                            'target_uid'  => $id,
                            'callback'=> ''
                        );
        $mutualFriends = $this->_instance->api($param);

    }

Unfortunately running this function once takes around 3 minutes.. multiply that by 10 times and you start making lunch after having started the script!

I was thinking of doing this using FQL as it is faster, and returns exactly the amount of data that I want (uid, name) I have tried

    $query = 'SELECT uid1 FROM friend WHERE uid2=me() AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=' . $id .') LIMIT 5';

But PHP throws an error: Can't lookup all friends of 1523223065. Can only lookup for the logged in user (665044728), or friends of the logged in user with the appropriate permission

Does someone know what to do??
PS: I have already seen all the other posts on stackoverflow about this, unfortunately without any success :(

Thank you very much!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

递刀给你 2024-10-18 00:27:07

据我所知,您不能再通过 FQL 来执行此操作。您的查询很好,并且它曾经工作过一段时间。但我认为 Facebook 已经改变了一切……

-Roozbeh

As far as I am aware, you can't do this through FQL anymore. The query you have is fine and it used to work a while back. But I think facebook has changed things...

-Roozbeh

你在看孤独的风景 2024-10-18 00:27:07

是的!我发现无论如何,这是唯一的方法。我鼓励每个人都使用 FBJS 进行任何查询,因为它的速度快得多! 2 分钟与 5 秒相比!

无论如何谢谢你!!

Yep! I figured out is the only way to do this, in any case.. I encourage everyone to user FBJS for any query as it is blazingly faster! 2 minutes compared to 5 seconds!

Thank you anyways!!

Dan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文