0

I am able to get friend list of friend of logged in user but of limited friends(app users) those having less friends except one friend.

Wait I am explaining in detail.

I am able to get friend list of friends those are app users. My 8 friends are app users. I am able to friends of 7 friends but I am not able to get friends of one friend. One difference found that he is having over 3300 friends others around 300.

I am getting this error

[Fri Mar 02 18:20:44 2012] [error] [client 192.168.1.2] PHP Fatal error: Uncaught Exception: 18: This API call could not be completed due to resource limits\n thrown in /var/www/jobjasoos/system/libraries/base_facebook.php on line 1040

I think it is because of large no. of friends. Is there any way to avoid this error?

I am using this fql query.

$query="SELECT uid, name, work FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid2 IN (SELECT uid2 FROM friend WHERE uid1 = $current_user) ) ORDER BY name";

$user_info=$facebook->api(array('method'=>'fql.query',
             'query'=>$query));

And I have seen following links, and didn't got any clue.

Community
  • 1
  • 1
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226
  • Now this query gives sometimes perfect result but sometimes it gives zero. My question is why fql behaves differently in different transactions? – Somnath Muluk Mar 05 '12 at 06:55

3 Answers3

0
$friends = $facebook->api('me/friends');
//print_r($friends['data']);
print_r("Number of Friends: ". count($friends['data']));
foreach ($friends['data'] as $key=>$listOfFriends) {
    echo "<br/>".$key." ".$listOfFriends['name']."<img src='https://graph.facebook.com/".$listOfFriends['id']."/picture' width='50' height='50' title='".$listOfFriends['name']."' />";     
}
0

Your server is not configured to download a request with so much info. You could try re-configuring your server, but I would suggest redesigning your app instead (if possible). That is, use the JavaScript SDK instead of PHP to get the friends list. This will offload the bandwidth usage from your server to your clients instead. My app uses the JS SDK to download 5000 friends with no problems.

To continue using php, see here: How can I optimize my FQL to avoid Facebook timeouts?

Community
  • 1
  • 1
Gil Birman
  • 35,242
  • 14
  • 75
  • 119
0

Write these two lines for avoiding timeouts when calling facebook then call facebook api.

set_time_limit(0); 
ini_set("memory_limit", "1024M");

$query="SELECT uid, name, work FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid2 IN (SELECT uid2 FROM friend  WHERE uid1 = $current_user) ) ORDER BY name";

$user_info=$facebook->api(array('method'=>'fql.query',
                'query'=>$query));
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226