I have gone through Realtime Update API documentation provided by Facebook & got successfully subscribed to the "page" object with the field as "feed", below is subscription url check which I used
URL:- https://graph.facebook.com//subscriptions?access_token=
which gave me the following response
RESPONSE:-
{
"data": [
{
"object": "page",
"callback_url": <CALLBACK_URL>,
"fields":
[
"feed"
],
"active": true
}
]
}.
This response clearly states that App is subscribed for feeds on the pages.
But my problem is that I am unable to receive any RealTime Update on the .
Below is the CALLBACK_URL php file code
<?php
define('VERIFY_TOKEN', <APPSECRET_KEY>);
$method = $_SERVER['REQUEST_METHOD'];
if(!empty($method))
{
if (!empty($_GET) && strcmp($method, 'GET') == 0 && strcmp($_GET['hub_mode'], 'subscribe') == 0 && $_GET['hub_verify_token'] == VERIFY_TOKEN)
{
echo $_GET['hub_challenge'];
}
else if (strcmp($method, 'POST') == 0)
{
file_put_contents(<FILE_PATH1>, "inside post method");
if (isset( $_SERVER['HTTP_X_HUB_SIGNATURE'] ) )
{
file_put_contents(<FILE_PATH2>, "inside post method");
$post_body = file_get_contents("php://input");
$object = json_decode($post_body);
file_put_contents(<FILE_PATH3>, json_encode($object));
if ($_SERVER['HTTP_X_HUB_SIGNATURE'] == "sha1=" . hash_hmac('sha1', $post_body, VERIFY_TOKEN))
{
//REST OF THE CODE TO SAVE IN DB
}
}
}
}
else
{
echo "Invalid Request, might be for testing purpose";
}
?>
Facebook is not sending any POST request to my CALLBACK_URL. Please let me know if I am missing anything
Finally I found the answer, just made a POST request to the below URL
https://graph.facebook.com/PAGE_ID/tabs?app_id=APP_ID&access_token=PAGE_ACCESS_TOKEN
I then started receiving Facebook Realtime Updates
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With