i’m trying to make an application, getting all the birthdays and other information from you facebook friends, using the facebook php sdk.
i get the friendlist and with a foreach loop, get all the info for every friends’ id.
This all works, only it takes 4 min+ to get all the information.
(for every friend i have to make a new call)
I can’t expect users of my application to wait that long.
Is there a way to get the info faster.
this is my code:
//$arrFriends is a list with all id's and names of friends
foreach ($arrFriends as $f => $value)
{
echo('');
$fql = "select uid, email, name, hometown_location, sex, birthday, education, relationship_status, pic_square from user where uid=" . $value[id];
$param = array('method' => 'fql.query','query' => $fql,'callback' => '');
$friend = $facebook->api($param);
//dan opslaan in de database:
print_r($friend);
echo('
');
}
You can use
Reference: https://developers.facebook.com/docs/reference/fql/
Same result, fast, quick, elegant solution. May the performance be with you.
Another solution (to be an idea for you)
If you have hundreds of friends, well that’s pretty normal and expected. You’re requesting Facebook API for hundres of times in the loop.
Many scalable facebook applications do that job asynchronously in the background (in a task queue) or maybe completely on a different machine to not to slow down and consume CPU bursts.
Try to use
ORconjuctives in your FQL queries.But in this case your FQL query gets larger and larger so that you have to be divide it. Therefore use first solution.