title: Facebook Page likes count with real time updates --> any better way?
body: <p>Smiirl is a physical real time likes counter for a specific Fb page (<a href="http://www.smiirl.com/fr/" rel="nofollow">www.smiirl.com/fr/</a>). </p>
  
  <p>I am wondering what is the best way to get the same result on a web page...
  I am using the php way with graph API and json decode, and then javascript refresh every 5 seconds... But I find it not reliable nor elegant.</p>
  
  <p>PHP : </p>
  
  <pre><code>&lt;!-- Header --&gt;
  $fb_id = "//YOUR FACEBOOK PAGE ID"
  $facebook_token = "//YOUR TOKEN";    
  $facebook_data = file_get_contents('https://graph.facebook.com/'.$fb_id.'?fields=likes&amp;access_token='.$facebook_token);
  $facebook_likes_var = json_decode($facebook_data);
  $unformatted_likes = $facebook_likes_var-&gt;likes;
  $facebook_likes = number_format($unformatted_likes, 0, ',', ' ');
  &lt;!-- Content --&gt;
  &lt;?php echo $facebook_likes; ?&gt;
  </code></pre>
  
  <p>JS :</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  setTimeout(function(){
  document.forms["reload"].submit();
  }, 5000);
  &lt;/script&gt;
  </code></pre>
  
  <p>Any of you know a way to do without having to reload ? Anyway to get some sort of channel to listen to and a push notification from Facebook ?</p>
  
  <p>Any example would be greatly appreciated ;)</p>
  
  <p>Thanks for your help !</p>
  
  <p>Vlad</p>