Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Facebook webhooks?

I want to configure Facebook webhooks for the application I'm developing.

What I did so far was:

  1. Create FB app
  2. Go to app settings and create a new webhook:
    1. Add a valid callback URLs
    2. Choose particular fields
  3. Successfully save the settings

Now, when I'm querying for page subscriptions I get the response:

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

which seems to be valid.

What should I do next? How to start listening from feed of a particular page?

like image 461
Kamil Lelonek Avatar asked Dec 09 '16 21:12

Kamil Lelonek


People also ask

Does Facebook use webhooks?

Webhooks allows you to receive real-time HTTP notifications of changes to specific objects in the Facebook Social Graph.

How do I set up webhooks?

You can install webhooks on an organization or on a specific repository. To set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook. Alternatively, you can choose to build and manage a webhook through the Webhooks API.

How do I get my Facebook callback URL?

In the "Facebook Login" tab under your app, enter all valid callback URL's, such as http://localhost/callback, http://productionUrl/callback, etc. If you don't see "Facebook Login" tab under your app, click "Add Product-> Facebook Login->Get Started" Enter the Valid Callback Urls -> Save changes. Save this answer.


1 Answers

Here is the entire configuration for Receiving API Updates in Real Time with Webhooks :

Step 1

  1. Create Facebook page
  2. Go to https://www.facebook.com/pg/YOUR_PAGE_NAME/about/?tab=page_info and read Facebook Page ID at the very bottom.

Step 2

  1. Create a developer account and a Facebook app
  2. Copy your Facebook App ID described in the above point.

Step 3

  1. Create a server application that will handle your Callback URL. A few examples are available on GitHub.
  2. Set up your Callback URL in the Facebook application you created in the previous step.

Step 4

Subscribe you Facebook App to your Facebook Page. To do that open Graph API Explorer.

  1. Obtain Page Access Token Alt text

Make sure you selected your particular application.

  1. After granting the permissions, select your particular page. The token will be put in Access Token field.
  2. Make POST request to the particular URL:

    /YOUR_PAGE_ID/subscribed_apps
    

Summary

That's it! With these steps you should have your server application up, running and listening on all events you declared!

like image 116
Kamil Lelonek Avatar answered Oct 14 '22 07:10

Kamil Lelonek