{"id":1455,"date":"2022-08-30T15:16:40","date_gmt":"2022-08-30T15:16:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/19\/how-to-do-fql-multiquery-using-facebook-php-sdk-3-0-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:40","modified_gmt":"2022-08-30T15:16:40","slug":"how-to-do-fql-multiquery-using-facebook-php-sdk-3-0-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-do-fql-multiquery-using-facebook-php-sdk-3-0-collection-of-common-programming-errors\/","title":{"rendered":"how to do fql.multiquery using facebook php sdk 3.0-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<p>For your particular query, use the new <code>fql<\/code> Graph API end-point and in only <em>one<\/em> query:<\/p>\n<pre><code>$user = $facebook-&gt;getUser();\nif ($user) {\n  try {\n    $fql = urlencode(\"SELECT uid, name, pic_square FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $user)\");\n    $response = $facebook-&gt;api(\"\/fql?q={$fql}\");\n  } catch (FacebookApiException $e) {\n    echo '<\/code><\/pre>\n<pre><code>'.htmlspecialchars(print_r($e, true)).'<\/code><\/pre>\n<pre>';\n    $user = null;\n  }\n}\n<\/pre>\n<p><code>Also use the <code>is_app_user<\/code> instead of the deprecated <code>has_added_app<\/code> one!<\/code><\/p>\n<\/li>\n<li>\n<p>Just pass queries as associative array:<\/p>\n<pre><code>  $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 ';\n  $fql = array(\n    'friends' =&gt; 'SELECT uid2 FROM friend WHERE uid1 = me()',\n    'friends_details' =&gt; $common_fields_fql . 'IN (SELECT uid2 FROM #friends)',\n    'me' =&gt; $common_fields_fql . '= me()',\n    'family' =&gt; 'SELECT uid, birthday, name, relationship FROM family WHERE profile_id = me()',\n  );\n  $details = $facebook-&gt;api(array(\n    'method'   =&gt; 'fql.multiquery',\n    'queries'  =&gt; $fql,\n  ));\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-19 13:17:36. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>For your particular query, use the new fql Graph API end-point and in only one query: $user = $facebook-&gt;getUser(); if ($user) { try { $fql = urlencode(&#8220;SELECT uid, name, pic_square FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $user)&#8221;); $response = $facebook-&gt;api(&#8220;\/fql?q={$fql}&#8221;); } catch (FacebookApiException $e) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1455","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1455"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1455\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}