how to do fql.multiquery using facebook php sdk 3.0-Collection of common programming errors
-
For your particular query, use the new
fql
Graph API end-point and in only one query:$user = $facebook->getUser(); if ($user) { try { $fql = urlencode("SELECT uid, name, pic_square FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $user)"); $response = $facebook->api("/fql?q={$fql}"); } catch (FacebookApiException $e) { echo '
'.htmlspecialchars(print_r($e, true)).'
'; $user = null; } }
Also use the
is_app_user
instead of the deprecatedhas_added_app
one! -
Just pass queries as associative array:
$common_fields_fql = 'SELECT uid, email, contact_email, first_name, last_name, birthday_date, pic_square, sex, hometown_location, current_location, is_app_user FROM user WHERE uid '; $fql = array( 'friends' => 'SELECT uid2 FROM friend WHERE uid1 = me()', 'friends_details' => $common_fields_fql . 'IN (SELECT uid2 FROM #friends)', 'me' => $common_fields_fql . '= me()', 'family' => 'SELECT uid, birthday, name, relationship FROM family WHERE profile_id = me()', ); $details = $facebook->api(array( 'method' => 'fql.multiquery', 'queries' => $fql, ));
Originally posted 2013-11-19 13:17:36.