Real Time Updates for Facebook Page


Today, I was trying to subscribe to real time updates from my Facebook pages. I had gone through all the related documents on Facebook API Docs, however, I didn't make it working. In many tutorials and docs, it was mentioned that page needs to install your application as a tab. I tried this way too. I got `200 OK` response and tab got added. However, No Luck! Sad, but I didn't find Facebook API Docs are good and clear enough.

After a long day research and hit & trails I get succeeded to get real time updates. I don't want others to suffer from the same situations. So, without taking a long, let me describe simple steps to follow to get real time updates for Facebook pages.

I will be using Graph API Explorer for describing the steps, you can follow it with any programming language.

  1. Get Page Access Token
    1.1 Get short term access token
        - Open Graph API Explorer Tool.
        - Select your application from dropdown.
        - Click on Get Access Token.
        - Check manage_pages under Extended Permissions and click Get Access Token.
        - Go to Now you need to make call to `/me/accounts`.
        - You will see a list of all accounts/pages associated with your developer account.
        - Copy Access Token  of the page that you want to subscribe for. This is the short term access token of the page which will have validity of around an hour.

    1.2 Exchange short term access token with long term access token
        - I have made it very simple for you. Just put details and click Get Long Term Access Token.


        - Replace APP_ID, APP_SECRET and SHORT_TERM_ACCESS_TOKEN in the URL below.
       - Copy and paste the updated URL in any of the browser's address bar and hit Enter. It should return true.
        - It will return a long term access token in the format like:
        - You can use Facebook's access token debug tool to check token details including validity.

 2. Page subscription to the App
    2.1 I have made it very simple for you. Just put details and click Subscribe to the page (should return true) OR get subscribed pages list (should return list of subscribed pages).


       - Replace PAGE_ID and PAGE_ACCESS_TOKEN in the URL below.
      - Copy and paste the updated URL in nay of the browser's address bar and hit Enter. It should return true.
       To validate the subscription, you can get the list of subscribed pages using following URL:
       It will return an array of subscribed pages.

That's it. Now whenever anything will get changed to your subscribed pages, you will get alert on specified path of your app.


  1. Sir thanks for the tutorial.
    How to specify the path of the app?

    1. Path is your website's URL (callback URL) on which Facebook will POST the updates. You can specify this URL while registering for real time update. You can check FB's doc here: (Setting Up your Callback URL)

    2. BTW, which programming language you are using?

    3. Thank you sir for your answer.
      I am using PHP.
      is it necessary to add the page in the "ADD PLATFORM" (adding App as a tab to a Page)?

    4. No, adding "Add Platform" is not mandatory.

    5. Sir last question. So, I did the configuration right. But nothing coming as a feed back.
      This is the code I have used :
      define('VERIFY_TOKEN', 'myString');
      $method = $_SERVER['REQUEST_METHOD'];

      if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == VERIFY_TOKEN) {

      echo $_GET['hub_challenge'];

      } else if ($method == 'POST') {

      if ( isset( $_SERVER['HTTP_X_HUB_SIGNATURE'] ) ) {
      $post_body = file_get_contents("php://input");

      if ($_SERVER['HTTP_X_HUB_SIGNATURE'] == "sha1=" . hash_hmac('sha1', $post_body, VERIFY_TOKEN)) {

      $object = json_decode($post_body, true);

      file_put_contents('updates.txt', $object , FILE_APPEND);


    6. I am not sure that I understand the question, however, it looks like you are expecting some data to be posted on this callback URL. This should happen when there will be some activity occurs on subscribed entity on Facebook.

      P.S.: is better place to proceed this communication. You can post your question there and there will be many hands to help. I am also active on SO too: :)

  2. Sir what will be the varify_token?

    1. `verify_token` is a manually specified string. It can be anything you want.

      From FB docs:
      When your server receives one of these requests, it needs to:

      Verify the hub.verify_token matches the one you supplied when creating the subscription. This is a security check so that your server knows the request is being made by Facebook and relates to the subscription you just configured.
      Render a response to the GET request that includes only the hub.challenge value. This confirms that this server is configured to accept callbacks, and is used for security verification on Facebook's side.

    2. Thanks for your help.
      I am new so this helps me a lot.

    3. I am glad that it helped you. Happy Coding!

    4. After following this tutorial i also used two urls but still no data is coming.
      1. To get App Access Token(got successfully) :

      2. and to subscribe the app(returned srccessful):

      Now got :
      "object": "page",
      "callback_url": "***",
      "fields": [
      "active": true

      but no out put is coming ....

    5. This is expected response. It's saying that your subscription for "feed" is ACTIVE now. Nothing is wrong with it.

  3. Thank you, Raj.
    You just saved my life.
    Now I can have real time update on my iOS app.

  4. A big thanks from me..
    After setting callback url, I spent lots of time but finally get a perfect steps here..

    1. It's my pleasure that you get your things working with the help of this.

  5. Hi,

    Thanks a lot for helping with this great post. Do you now why sometimes facebook sends same data in two or more time periods. Sometimes it is just once, but sometimes it is repeating. For example I write status on page at 22:00, I get one call at 22:02 and second on 22:03 with same data.

    1. From when you are facing this problem? I remember sometime earlier, Facebook had published this thing in known issues and they were working on this.


Post a Comment