开发者

FQL: obtaining mutual friends making less queries possible

开发者 https://www.devze.com 2023-02-02 23:41 出处:网络
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 a

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!!


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消