0

I am currently using Facebook's PHP API to gather data of mutual friends. I am currently querying as suggested in here: Facebook mutual friends and FQL 4999/5000 record limit, using the array_chunk method. Can I ask what are the possible reasons for the above error thrown? What are the possible resource limitations?

At first, I tried to increase the memory limit of the php script to 128MB, but I used memory_get_usage(true) and it gave me a number much less than that (after conversion, it was less than 3MB) when I caught the above-mentioned Facebook error.

Is this a resource limitation due to Facebook, or my script?

Here is my written code:

$chunked_friends = array_chunk($all_friends_id, 100); // we use 100 for now, if there is loss of information, then we consider another way

foreach ($chunked_friends as $array) {
  $mutualfriends = $facebook->api(array(
    'method' => 'fql.query',
    'query' => 'SELECT uid1, uid2 FROM friend 
                WHERE uid2 IN 
                (SELECT uid2 FROM friend WHERE uid1=me())   
                AND uid1 < uid2 
                AND uid1 IN ( '. implode(', ', $array) .' )'
    ));

  foreach ($mutualfriends as $mutualfriend) {
        $returned_array["links"][] = array("source" => $mutualfriend['uid1'], "target" => $mutualfriend['uid2']);
  }
    usleep(200000);
}

Edit: I am using heroku to develop my app currently.

Community
  • 1
  • 1
Yuling
  • 41
  • 1
  • 3

2 Answers2

0

Is this a resource limitation due to Facebook

Yes.

Check your app insights (section „API”) to see if it’s specific to your application (too many/too large requests over a given period of time).

CBroe
  • 91,630
  • 14
  • 92
  • 150
0

In the end, I used the batch requests and this seemed to have solved the problem. I'm not exactly sure what constitutes as too many API calls since FB doesn't really say either.

Yuling
  • 41
  • 1
  • 3