I am using the Facebook Graph API and I was wondering if there was anyway to get a list of all the users and their current status in one call?
I basically want the s
While the new Batch API should do what you are asking for, I couldn't manage to make it work properly. It seems that it's still buggy.
Now to achieve this with fql.multiquery, here's a quick example:
top.location.href='" . $dialog_url
. "'");
}
$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$access_token = file_get_contents($token_url);
$queries = '{"query1":"SELECT uid,name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1=me())","query2":"SELECT uid,message FROM status WHERE uid IN (SELECT uid FROM #query1)"}';
$multiquery = "https://api.facebook.com/method/fql.multiquery?queries=" . urlencode($queries) . "&format=json&" . $access_token;
$res = json_decode(file_get_contents($multiquery), TRUE);
$final = array();
foreach( $res[1]['fql_result_set'] as $i=>$message_arr ) {
foreach( $res[0]['fql_result_set'] as $j=>$friend ) {
if( $message_arr['uid'] == $friend['uid'] ) {
$friend['message'] = $message_arr['message'];
$final[] = $friend;
break;
}
}
}
print_r($final);
?>
Here we are getting the user id and name in the first query and getting the status messages from the second one.
Now this would return fewer results in the first query or the second! because:
break
).