php - Facebook Real Time update not working as expected

858

I registered for real time updates feature and I verified it as well here's the response which I get when I tried to see whether my subscription was success or not

{
   "data": [
      {
         "object": "user",
         "callback_url": "http://ghl.raiseit-bd.com/callback-page.php",
         "fields": [
            "feed"
         ],
         "active": true
      }
   ]
}

Now when I made a post on my wall, I was expecting that facebook will call my callback url and things will get written to a text file

Here's code for callback-page.php

<?php
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == 'Our1stFBApp') {

   echo $_GET['hub_challenge'];
   exit;

}
else
{
  $updates = json_decode(file_get_contents("php://input"), true); 
  $myFile = "testFile.txt";
  $fh = fopen($myFile, 'w') or die("can't open file");
  $stringData = $updates;
  $stringData = $stringData.'Hello';
  fwrite($fh, $stringData);
  fclose($fh);
  print_r($stringData, true));       

}

?>

the file textFile.txt resides inside root directory.

But nothings getting written in that file. How will I know that the real-time update feature is working..any help would be greatly appreciated

People are also looking for solutions to the problem: php - Export Yii Models with Relations into diagram

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.