开发者

Facebook GetMutualFriends Method failing for no clear reason

I've an application that runs on a webpage, it has a list of facebook id's and run through them checking if the logged user has any mutual friends with the id's on the list; for making this verificaton I'm using the Rest API with the friends.getMutualFriends metond, I'm using this method becasue in this way I can get the mutual friends without having both users authenticated, I just need the authentication for the origin userid, in the case of FQL or using the Graph API both users should be connected so that I can get the mutual friends, this is why the getMutualFriends method is so useful in this case. The problem that I'm having is that when I try to pull the mutual friends for a user that has a lot of friends then I get this error

"error_code": 18, "error_msg": "This API call could not be completed due to resource limits",

if I try to do that with a user that has less frineds the in will work, I know that saying less or a lot is novet very accurate , so , lets take a look at this example, if I try to execute this call with a user that has 300 friends the call will work, but if I try to do that exact same thing with a user that has 700 friends it'll return back with the error that I put above, so I thought that it could be the amount of calls per second so I limited that but it did not worked, I tried resetting the app keys, I've tried with several differente users, I've tried to do it with a new application, and even if I just try make one call to compare 2 users it'll fail if the user has a large amout of friends, the code that I'm using for this is

function getMutualFriends($facebook, $uid1, $uid2)
{
    try
    {
        $param  =   array(
            'method'  => 'friends.getMutualFriends',
            'source_uid'    => $uid1,
            'target_uid'  => $uid2,
            'callback'=> ''
            );
        $mutualFriends   =   $facebook->api($param);
        return $mutualFriends;

    }

    catch(Exception $o)
    {
              return serialize($o);
    }

    return null;
}

function getMutualFriendInfo($facebook, $uid1, $uid2)
{

    $mutualfriends=getMutualFriends($facebook, $uid1, $uid2);
 开发者_如何学编程   if (is_array($mutualfriends))//!=''))
    {
        $friend_uids = implode(",",$mutualfriends);
        try
        {
            $param = array(
                'method' => 'users.getInfo',
                'uids' => $friend_uids,
                'fields' => 'name,pic_square,pic_big',
                'callback' => ''
                );
            $friend_info = $facebook->api($param);
            return $friend_info;
        }
        catch (Exception $o)
        {
             return serialize($o);
        }
    }
    return serialize($mutualfriends);
}

So my questions are, is there anything that I'm doing wrong on this cade so that it fails? Is there any othere way to do this besides the friends.GetMutualFriends method? I've already tried with this SELECT uid1 FROM friend WHERE uid2=[targetID] AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=[sourceID]) but it did not worked. Is there any specific origin on this error?

I'm very confused because it works for some users and it doesn't for others, I've searched if there's any api limit but I've not found anything on that, there are no errors on the API dashboard, this code seemed to work before, and if I execute the call on the test console on facebook I'll get the same error,

Thanks for are your help, any idea will be appreciated.


There's a bug reported in facebook.

http://bugs.developers.facebook.net/show_bug.cgi?id=15644


firstly you should migrate from old rest api to new graph api.... because facebook will obsolete the old rest api soon. secondly try this query

SELECT uid1 FROM friend WHERE uid2='your user id'

I hope that it will work

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜