Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;?php // displays some comments for a certain url $url = 'http://developers.facebook.com/docs/reference/fql/comment/'; // fql multiquery to fetch all the data we need to display in one go $queries = array('q1' =&gt; 'select post_fbid, fromid, object_id, text, time from comment where object_id in (select comments_fbid from link_stat where url ="'.$url.'")', 'q2' =&gt; 'select post_fbid, fromid, object_id, text, time from comment where object_id in (select post_fbid from #q1)', 'q3' =&gt; 'select name, id, url, pic_square from profile where id in (select fromid from #q1) or id in (select fromid from #q2)', ); // note format json-strings is necessary because 32-bit php sucks at decoding 64-bit ints :( $result = json_decode(file_get_contents('http://api.facebook.com/restserver.php?format=json-strings&amp;method=fql.multiquery&amp;queries='.urlencode(json_encode($queries)))); $comments = $result[0]-&gt;fql_result_set; $replies = $result[1]-&gt;fql_result_set; $profiles = $result[2]-&gt;fql_result_set; $profiles_by_id = array(); foreach ($profiles as $profile) { $profiles_by_id[$profile-&gt;id] = $profile; } $replies_by_target = array(); foreach ($replies as $reply) { $replies_by_target[$reply-&gt;object_id][] = $reply; } /** * print a comment and author, given a comment passed in an an array of all profiles. * @param object $comment as returned by q1 or q2 of the above fql queries * @param array $profiles_by_id, a list of profiles returned by q3, keyed by profile id * @returns string markup */ function pr_comment($comment, $profiles_by_id) { $profile = $profiles_by_id[$comment-&gt;fromid]; $author_markup = ''; if ($profile) { $author_markup = '&lt;span class="profile"&gt;'. '&lt;img src="'.$profile-&gt;pic_square.'" align=left /&gt;'. '&lt;a href="'.$profile-&gt;url.'" target="_blank"&gt;'.$profile-&gt;name.'&lt;/a&gt;'. '&lt;/span&gt;'; } return $author_markup. ' ('.date('r', $comment-&gt;time).')'. ': '. htmlspecialchars($comment-&gt;text); } print '&lt;html&gt;&lt;body&gt;'; // print each comment foreach ($comments as $comment) { print '&lt;div style="overflow:hidden; margin: 5px;"&gt;'. pr_comment($comment, $profiles_by_id). '&lt;/div&gt;'; // print each reply if (!empty($replies_by_target[$comment-&gt;post_fbid])) { foreach ($replies_by_target[$comment-&gt;post_fbid] as $reply) { print '&lt;div style="overflow:hidden; margin: 5px 5px 5px 50px"&gt;'. pr_comment($reply, $profiles_by_id). '&lt;/div&gt;'; } } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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