title: Pushing data to user browser from server
body: <p>I want to push data from server to browser. I am already aware of php function <code>ob_flush()</code> which sends output buffer. I need help with a bit of logic. I am using Facebook real time API so i want to push data to user everytime Facebook visits my website.</p>
  
  <p>Here is my code that i am trying to push data to browser but its not working.</p>
  
  <pre><code>&lt;?php
  header('Access-Control-Allow-Origin: *');
  header('Content-Type: text/event-stream');
  ini_set("log_errors", 1);
  ini_set("error_log", "php-error.log");
  error_log( "LOGS STARTS FROM HERE" );
  if(isset($_GET['hub_challenge'])){
      echo $_GET['hub_challenge'];    
  }
  if($_SERVER['REQUEST_METHOD'] == "POST"){
      $updates = json_decode(file_get_contents("php://input"), true); 
      // Replace with your own code here to handle the update 
      // Note the request must complete within 15 seconds.
      // Otherwise Facebook server will consider it a timeout and 
      // resend the push notification again.
      print_r($updates);
      ob_flush();
      flush();
      //file_put_contents('fb.log', print_r($updates,true), FILE_APPEND);     
      //error_log('updates = ' . print_r($updates, true));              
  }
  ?&gt;
  </code></pre>