php - Facebook Real Time update not working as expected
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