views:

20

answers:

2

Hey guys

I'm using the facebook graph PHP sdk - whenever I call the $facebook->api method in a loop I end up getting this error

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Apache\htdocs\fb\application\library\facebook-platform\php\facebook.php on line 509

This is the sample code

$data = $facebook->api('/me/likes');
foreach($data['data'] as $like)
{
   $test = $facebook->api($like['id']);     
}

Is it because of any limit. Thanks

+1  A: 

Looks like just a standard php timeout, not facebook related. Just put set_time_limit(0); in front of your script.

serg
Thanks dude - it totally didn't occur to me :)
Gublooo
+1  A: 

Calling the API in a loop like that will have terrible performance. You probably want something like:

$facebook->api('/me/likes', array('fields' => 'name,link'))

This will do most of what you're doing in one shot. You can add more fields that you use from the response from the call inside the loop.

daaku

related questions