Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A Recommendation is a Like. You can see it in the reference of the like button :</p> <blockquote> <p><code>action</code> - the verb to display on the button. Options: 'like', 'recommend'</p> </blockquote> <p>To get the counts for a URL (here <code>http://stackoverflow.com</code>), you can make an FQL call :</p> <pre><code> SELECT url, share_count, like_count, comment_count, total_count FROM link_stat WHERE url="http://stackoverflow.com" </code></pre> <h1>Call directly</h1> <pre><code>$fql = 'SELECT url, share_count, like_count, comment_count, total_count FROM link_stat WHERE url="http://stackoverflow.com"'; $json = file_get_contents('https://api.facebook.com/method/fql.query?format=json&amp;query=' . urlencode($fql)); </code></pre> <p>And <code>$json</code> will contain :</p> <pre><code>[ { "url" : "http://stackoverflow.com", "share_count" : 1353, "like_count" : 332, "comment_count" : 538, "total_count" : 2223 } ] </code></pre> <p>You have here :</p> <ul> <li><code>share_count</code> : the counts of shares for the URL</li> <li><code>like_count</code> : the count of likes (= recommendations)</li> <li><code>comment_count</code> : the count of comments in Facebook below shares of that link</li> <li><code>total_count</code> : the sum of theses 3 counts</li> </ul> <p>You can read json in PHP with <code>json_decode</code> :</p> <pre><code>$data = json_decode($json); echo $data[0]-&gt;like_count; </code></pre> <h1>Use the Facebook PHP SDK</h1> <p><strong>EDIT</strong> : As Rufinus pointed out int the comments of his answer, for stability reasons, if you are on a long term project and not just a quick experiment you should use the Facebook PHP SDK (<a href="http://github.com/facebook/php-sdk" rel="noreferrer">see on github</a>) to make FQL queries : <strong>Facebook is more and more closing public access</strong> (read without access token) to its API (see <a href="http://developers.facebook.com/blog/post/509/" rel="noreferrer">this blog post on Facebook developers blog</a>). Even like here when theses queries are not related to any user : the SDK is using the app access token to make the query.</p> <pre><code>require "facebook.php"; $facebook = new Facebook(array( 'appId' =&gt; YOUR_APP_ID, 'secret' =&gt; YOUR_APP_SECRET, )); $fql = 'SELECT url, share_count, like_count, comment_count, click_count, total_count FROM link_stat WHERE url="http://stackoverflow.com"'; $result = $facebook-&gt;api(array( 'method' =&gt; 'fql.query', 'query' =&gt; $fql, )); </code></pre> <p>The <code>$result</code> array contains what you need (<code>like_count</code> field) and even more :</p> <pre><code>Array ( [0] =&gt; Array ( [url] =&gt; http://stackoverflow.com [share_count] =&gt; 1356 [like_count] =&gt; 332 [comment_count] =&gt; 538 [click_count] =&gt; 91 [total_count] =&gt; 2226 ) ) </code></pre>
 

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