$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 the query. It works me faster because I have limited friends. But some app users say that it is very very slow for them if they have about 2000+ friends. They said it took 30 seconds to minutes too.
Why it is very slower? Is there any wrong in this request?
Well, the first thing – as long as you filter users by
uidand only selectuidafter that – the outer query looks redundant. So the final query can be reduced toThe second thing: it is a bit more handy to use fb php sdk to perform FQL queries, not
file_get_contents, like:(taken from https://stackoverflow.com/a/7827550/251311)