Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>While the new <a href="http://developers.facebook.com/docs/api/batch/" rel="nofollow noreferrer">Batch API</a> should do what you are asking for, I couldn't manage to make it work properly. It seems that it's still buggy. </p> <p>Now to achieve this with <a href="https://developers.facebook.com/docs/technical-guides/fql/#multi" rel="nofollow noreferrer"><code>fql.multiquery</code></a>, here's a quick example: </p> <pre><code>&lt;?php $app_id = "APP_ID"; $app_secret = "APP_SECRET"; $my_url = "REDIRECT_URL"; $code = $_REQUEST["code"]; if(empty($code)) { $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url); echo("&lt;script&gt; top.location.href='" . $dialog_url . "'&lt;/script&gt;"); } $token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;client_secret=" . $app_secret . "&amp;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) . "&amp;format=json&amp;" . $access_token; $res = json_decode(file_get_contents($multiquery), TRUE); $final = array(); foreach( $res[1]['fql_result_set'] as $i=&gt;$message_arr ) { foreach( $res[0]['fql_result_set'] as $j=&gt;$friend ) { if( $message_arr['uid'] == $friend['uid'] ) { $friend['message'] = $message_arr['message']; $final[] = $friend; break; } } } print_r($final); ?&gt; </code></pre> <p>Here we are getting the user id and name in the first query and getting the status messages from the second one.<br> Now this would return fewer results in the first query or the second! because: </p> <ul> <li>A friend may have not posted a status message for the <a href="http://developers.facebook.com/docs/reference/fql/status/" rel="nofollow noreferrer">last 30 days</a>, so it won't appear in the second query (second has fewer result set).</li> <li>A friend may have posted more than one status message in the last 30 days (it <em>should</em> return them all - up to 50 ?!!) I'm not sure, but if this is the case then the second will/should return more results than the first one. So I'm getting only <strong>one</strong> message (notice the <code>break</code>).</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload