15

I'm trying to stream the real time public feeds using Facebook Web-hook API. Here I'm trying to set up a page subscription in Web-hook console. There is a field called Callback URL. What is this URL about?

I have also tried going through the documentation for Setting up callback URL. but I Couldn't figure out.

https://developers.facebook.com/docs/graph-api/webhooks#setup

Cant the callback URL be SSL localhost? Whenever I try to give a localhost URL i get a error message "Unable to verify provided URL".

Karthick Radhakrishnan
  • 1,151
  • 3
  • 12
  • 32
  • 2
    Facebook will make a request to that URL from their servers to deliver the updates – so of course it has to be publicly reachable over the internet, which a localhost address obviously isn’t. – CBroe Jan 13 '16 at 08:33
  • Ok. will this url be called by facebook API when I stream for feeds? How do i get response feed object? – Karthick Radhakrishnan Jan 13 '16 at 08:57
  • 1
    Facebook will send a request to that URL if any data for the object and fields that you subscribed for changes. And what the data structure looks like, is described in the docs. For page fields it returns the new content directly; for user fields it will only tell you which fields have changed, so that you can then make a request for that data. – CBroe Jan 13 '16 at 09:04
  • Thank you CBore. It was really helpful. but on other context i'm trying to listen public feeds irrespective of any page from facebook. Is that possible with facbook API? I heard the Public Feeds API's are depreciated? Is that correct? is there anyway i can stream feeds? – Karthick Radhakrishnan Jan 13 '16 at 09:38
  • 1
    You can only get real-time updates for pages that you have admin access to. And the Public Feed API is not deprecated; but access to it is limited to a small set of Facebook partners. You can not apply to become one – if you absolutely need this kind of data, then you’ll have to contact one of those partners and have them develop a solution for you. – CBroe Jan 13 '16 at 09:42
  • Again! That was a good info! Thanks a lot. – Karthick Radhakrishnan Jan 13 '16 at 09:44

4 Answers4

24

You can forward the request to localhost with the following:

  1. Download and install ngrok from https://ngrok.com/download
  2. ./ngrok http 8445
  3. Subscribe your page to the Webhooks using verify_token and https://<your_ngrok_io>/webhook as callback URL.
  4. Talk to your bot on Messenger!
Phil Hudson
  • 3,819
  • 8
  • 35
  • 59
4

Facebook will make a request to that URL from their servers to deliver the updates – so of course it has to be publicly reachable over the internet, which a localhost address obviously isn’t.

Facebook will send a request to that URL if any data for the object and fields that you subscribed for changes. And what the data structure looks like, is described in the docs. For page fields it returns the new content directly; for user fields it will only tell you which fields have changed, so that you can then make a request for that data.

You can only get real-time updates for pages that you have admin access to. And the Public Feed API is not deprecated; but access to it is limited to a small set of Facebook partners. You can not apply to become one – if you absolutely need this kind of data, then you’ll have to contact one of those partners and have them develop a solution for you.

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • "You can only get real-time updates for pages that you have admin access to" So in my application I can't use webhook to notify the user for changes in the pages he desires, for examples when a page post a new video, photo or post? – Ashraf Alshahawy Feb 14 '16 at 06:52
  • 1
    Only if the user or you are an admin of the page, so that you can use their/your user access token to generate a page access token for that page. – CBroe Feb 14 '16 at 07:02
  • So currently it's not possible to implement in my application a feature similar to Facebook over web [ Notifications (All posts - videos - photos - links - status updates) ] ... So, is there another way to allow my application users to follow the pages they desires and get notified when these pages publish videos for example? Because using a periodic check for a number of pages for each customer is not a desirable solution for me. – Ashraf Alshahawy Feb 14 '16 at 07:18
  • Isnt there any way we can use localhost for webhooks for facebook? – Muneeb Zulfiqar Apr 13 '16 at 16:17
0

I think it means that you need a server which has a fixed IP address. If you want to use the real time update from the Facebook, you need to build a server which receive the post request from Facebook and meanwhile keep a long connection to you endpoint so that the endpoint can receive message pushed by the server.

Jason
  • 1
  • 1
0

You have to write a webhook to get the fb request from fb server as well as the webhook should be running in a public ip address, this public url is the one to be filled it out on the callback url box. So that the fb server could update you through the url which is nothing but the url of running webhook. To get the public url address for fb recognising your webhook, you can use ngrok or can host your webook in heroku.