Facebook Realtime API Updates for Page Submission

I looked at the Realtime Update API documentation provided by Facebook and successfully subscribed to the page with the field as "feed" , below - the subscribed URL, check that I used

URL: - https://graph.facebook.com/ / subscriptions? access_token =

who gave me the following answer

ANSWER: -

{ "data": [ { "object": "page", "callback_url": <CALLBACK_URL>, "fields": [ "feed" ], "active": true } ] }. 

This answer clearly states that the application is subscribed to channels on the pages.

But my problem is that I cannot get RealTime's update.

Below is the PHP file code CALLBACK_URL

 <?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 a POST request to my CALLBACK_URL. Please let me know if I missed something.

+6
source share
1 answer

Finally, I found the answer, just made a POST request to the URL below

https://graph.facebook.com/PAGE_ID/tabs?app_id=APP_ID&access_token=PAGE_ACCESS_TOKEN

Then I started getting real-time Facebook updates

+4
source

Source: https://habr.com/ru/post/979398/


All Articles