title: How to count likes on FB page?
body: <p>I have to do a very simple operation but my programming skills are not enough. I have to count likes in Facebook page and print that number on my web-site. I have two scripts that do the job well for ordinary web-sites, but they don't want to show the number of likes for the page.</p>
  
  <pre><code>&lt;?php
  $source_url = "http://www.facebook.com/";  //This could be anything URL source  including stripslashes($_POST['url'])
  $url = "http://api.facebook.com/restserver.php?method=links.getStats&amp;urls=".urlencode($source_url);
  $likes =  $xml-&gt;link_stat-&gt;like_count;
  $comments = $xml-&gt;link_stat-&gt;comment_count;
  $total = $xml-&gt;link_stat-&gt;total_count;
  $max = max($shares,$likes,$comments);
  echo $likes;
  ?&gt;
  
  &lt;?php
  $fql  = "SELECT url, normalized_url, share_count, like_count, comment_count, ";
  $fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM ";
  $fql .= "link_stat WHERE url = 'http://www.apple.com/'";
  $apifql="https://api.facebook.com/method/fql.query?format=json&amp;query=".urlencode($fql);
  $json=file_get_contents($apifql);
  print_r( json_decode($json));
  ?&gt;
  </code></pre>
  
  <p>Both scripts work for ordinary web-sites but cant fetch fb page likes number. May be I should enter the link in another format or something?</p>
  
  <p>I can get required data using graph like this <a href="http://graph.facebook.com/?ids=AutoSpecCenter" rel="nofollow">http://graph.facebook.com/?ids=AutoSpecCenter</a> , just by entering page name like that. But I don't know how to manipulate with this data.</p>