What is the counterpart of Twitter Streaming API for Facebook Fan Page?
How can i get real time updates from a Facebook Fan Page?
You have to use the realtime api from facebook : http://developers.facebook.com/docs/api/realtime/
To do what you ask, you must subscribe to page
objects and their feed
connection.
To add a subscription you have to send a POST request to :
https://graph.facebook.com/<app-id>/subscriptions?access_token=...
And for that you need an access token that you can get at :
https://graph.facebook.com/oauth/access_token?client_id=<app-id>&client_secret=<app-secret>&grant_type=client_credentials
The fields that have to be in the POST data are :
object
- The type of the object to monitor, e.g. “user” or “permissions”. You will monitor all objects of that type; for example, all users of your application.fields
- A comma-separated list. This is a list of properties or connections on the specified object. For example, to monitor changes to user's name, picture, friends, and News Feed, you would specify “name,picture,friends,feed”callback_url
- A callback URL to which Facebook will post subscription updates.And you can specify
verify_token
- A subscriber-provided opaque token that will be echoed back in the verification request to assist the subscriber in identifying which subscription request is being verified. If this is not included, no token will be included in the verification request. This is from the PubSubHubbub spec.Once your callback url has been verified, you will receive updates when data change in the feed of the page on your callback url as json objects, here is an example for a user :
{
"object": "user",
"entry":
[
{
"uid": 1335845740,
"changed_fields":
[
"name",
"picture"
],
"time": 232323
},
{
"uid": 1234,
"changed_fields":
[
"friends"
],
"time": 232325
}
]
}
You can also do GET and DELETE on the same URL to get the list of your subscriptions, and to delete subscriptions.
But all the details are in the facebook doc
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