Facebook FQL - very slow

$access_token = $facebook->getAccessToken();
$query = "SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())";
$query = urlencode($query);
$fql_query_url = 'https://graph.facebook.com/'. 'fql?q='.$query. '&access_token=' .    $access_token;
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);

This is a request. It works faster because I have limited friends. But some users of applications say that it is very slow for them if they have about 2000+ friends. They said it took 30 seconds and minutes.

Why is this slower? Are there any errors in this request?

+5
source share
3 answers

Well, firstly, as long as you filter users by uidand select uidafter that - an external query looks redundant. Thus, the final request can be reduced to

SELECT uid2 FROM friend WHERE uid1=me()

Second: it is slightly better to use fb php sdk to execute FQL queries, rather than file_get_contents, for example:

$facebook->api("/fql?q={$fql}");

( fooobar.com/questions/1120244/...)

+4

, . 2000+ ...

- https://developers.facebook.com/live_status.

( ), , API API. , , , .

+1

, FQL , , API- . , , .

FB.api("me/friends?fields=id&limit=3000", function(resp){//process data});
0

All Articles