I have setup realtime facebook update for both user and page. Whenever user updates his status, I get request on my server about the change. The data I get from facebook post call is like below.
{
"object":"user",
"entry":[
{
"uid":"10152689315982483",
"id":"10152689315982483",
"time":1427362347,
"changed_fields":[
"feed"
]
}
]
}
But I did not get any call from facebook when admin of a page update its status.
I followed the below steps to get the realtime facebook update.
Subscribe user/page to get updates with access token.
graph.facebook.com//subscriptions?object=user&fields=feed&verify_token=&method=post&callback_url=htps://serverurl/realtime.php
To get the list of subscription
graph.facebook.com//subscriptions
From this call I get both user and page data.
{
"data": [
{
"object": "user",
"callback_url": "https://serverurl/realtime.php",
"fields": [
"feed"
],
"active": true
},
{
"object": "page",
"callback_url": "https://serverurl/realtime.php",
"fields": [
"feed"
],
"active": true
}
]
}
I also added the app to page-tab but still not getting the updates for page. Could anyone tell me what I am missing?
Do an http GET on
https://graph.facebook.com/v2.3/{page-id}/subscribed_apps?access_token=PAGE_ACCESS_TOKEN
If your app is not listed, you need to "install it" (this is an alternative installing the app as a page tab app). Do this by issuing a post request to the same url. Eg with curl,
curl -X POST "https://graph.facebook.com/v2.3/{page-id}/subscribed_apps?access_token=PAGE_ACCESS_TOKEN"
You don't need to supply any parameters since the id of the app you wish to install is inferred from the access token.
If /subscribed_apps already includes your app id, you may be experiencing a bug and should report it at http://developers.facebook.com/bug
Related
I subscribed to feed webhook and I ve receiving posts everytime the user navigate and search something.
Is the expected behavior because documentation say:
Describes changes to most sections of the user's profile, such as About, Photos, Posts, Friends, and Likes
The json that I receive is:
{
"entry":
[
{
"time": 542196889466880,
"id": "0",
"changed_fields": ["feed"],
"uid": "XXXXXXXXXXXXX"
}],
"object": "user"
}
Can you provide JSON of Facebook you receive when the user navigate and search something?
I'm using webhook. I've only subscribed to webhook feed, and I only receive event data when user comment/post/reaction in my page.
Does Facebook have a webhook that an app can subscribe to to detect when a Facebook event is added to a page? Or do apps that are interested in this information just have to repeatedly poll /[page-id]?fields=events ?
For example if you have a page that creates some event, as long as you subscribe to feeds, Facebook Realtime API will send you json payload that looks similar to this:
{
"entry": [
{
"changes": [
{
"field": "feed",
"value": {
"story": "Some page added an event.",
"item": "event",
"event_id": "2277580782468248",
"post_id": "1442694315844896_2277580782468248",
"verb": "add",
"created_time": 1511651353,
"message": "test event"
}
}
],
"id": "1442694315844895",
"time": 1511651355
}
],
"object": "page"
}
Then you probably would like to pull the Graph API for additional informations about your event_id
The product you are trying to find is Facebook Webhooks https://developers.facebook.com/docs/graph-api/webhooks/. It allows you to subscribe to changes on the Facebook page and get alert only when change occures. You don't need to have regular calls with Graph API to see whether there are changes.
First you need to create facebook app, and then to add webhooks on that Facebook app. Next step is to subscribe that webhook to page you want and select "feed" as subscription. You will be informed about any change on your page.
I'm setting up Facebook Real-time updates for an app so that I can read user's status updates as they happen, but I'm not getting updates. As far as I can tell I've set everything up correctly. Here's my subscription:
{
"data": [
{
"object": "user",
"callback_url": "*****/facebook-rt-callback.aspx",
"fields": [
"checkins",
"feed"
],
"active": true
}
]
}
When I test my subscription, my callback gets the request and FB shows that it worked correctly.
When user's give access to my app, I request scope=user_status,user_checkins. I also have these permissions defined in my app on FB. My test user is able to login and give permission to my app, but when the test user posts status updates or checkins on his timeline, my callback never gets hit.
Any ideas? Thanks.
I'm writing a facebook web app with Graph API for publishing on a page wall automatically. I'm the page administrator and I've set up the app permissions for requiring manage_pages, offline_access, read_stream and publish_stream. My app will be like twitterfeed app with something different (I've no rss feed as a source).
For the first step I call:
https://graph.facebook.com/oauth/access_token?client_id=".$app_id."&client_secret=".$app_secret."&grant_type=client_credentials
When this call return an access_token I call:
https://graph.facebook.com/100344706779072?fields=access_token&access_token=". $access_token
Here I have problems: as facebook doc says (https://developers.facebook.com/docs/reference/api/page/#page_access_tokens) I must get page_access_token in this way, but this call return only the page id..
So what I'm doing wrong?
From the facebook docs here: https://developers.facebook.com/docs/howtos/login/login-as-page/
you need to use the access token you got in the first call and make a second call to https://graph.facebook.com/me/accounts?access_token=$access_token
and you'll get a reply that looks like this:
{
"data": [
{
"name": "PAGE_TITLE",
"access_token": "PAGE_ACCESS_TOKEN",
"category": "PAGE_CATEGORY",
"id": "PAGE_ID"
},
{
"name": "PAGE_TITLE",
"access_token": "PAGE_ACCESS_TOKEN",
"category": "PAGE_CATEGORY",
"id": "PAGE_ID"
},
...
]
}
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