Information in Feed Weebhook - facebook

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.

Related

Facebook Webhooks Pages: Get likes and unlikes

I've set up a webhook in facebook properly and I'm receiving feed updates. So I will be notificated by adding a like, changing a comment and so on.
But when I dislike the page, there is no action send. I dont not receive anything.
I get this one, when a user adds a like:
{"entry": [{"changes": [{"field": "feed", "value": {"item": "like", "verb": "add"}}], "id": "216046745080249", "time": 1556272643}], "object": "page"}
How to determine if a user dislikes the page?? And maybe get something similar?

Does Facebook have a webhook that an app can subscribe to to detect when a Facebook event is added to a 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.

Facebook real time update for user and page

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

Facebook: Link Request's sender to it's recipient?

When using the requests dialog, facebook issues a notification like this:
What I'm looking to achieve is for the user to click the request link shown above and to present a "Random User invited you to..." message on our App.
However, when clicking that link Facebook doesn't seem to pass through the id of "Random User" to the App. The url accessed by the link looks something like:
http://apps.facebook.com/randomcomp/?fb_source=notification&request_ids=350578327437399,350578327437399&ref=notif&app_request_type=user_to_user&notif_t=app_request
which doesn't contain any reference to the user who initiated the request.
From the App's side, there doesn't seem to be a way to get this information from Facebook. Sure, you can get a list of requests, but that list can contain information for many requests, including requests from other users in addition to the one we're interested in, so it's not useful in this case. For example, here's a snapshot of data:
{
"data": [
{
"id": "340083146057323_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Random User",
"id": "100002286042525"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T13:26:30+0000"
}, {
"id": "358318457550141_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Jane Young",
"id": "100003771838663"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T10:54:25+0000"
}],
}
}
As you can see, the data is being passed in, but there's still no way to join the click from the link mentioned above (for Random User) to the correct request in the list; the link passes through the ID for both requests, not just the one for Random User, and while the link states "Random User" it doesn't pass through an identifier.
Am I missing something? Is there a mechanism that isn't in the docs that will allow me to pick-up the "Random User" id so I can provide a nice "Random User invited you to..." message in the App when they click through?
Edit:
Turns out that this isn't possible - see my answer.
You can add some data to the request so that when you process the request you can differentiate that from other requests.
The data can be sent with app requests and users requests and the parameter name is "data".
For example, in the guide for the Requests Dialog you can see it in the properties table at the (almost) end of the document, it says:
Optional, additional data you may pass for tracking. This will be
stored as part of the request objects created. The maximum length is
255 characters
There's also some info about it in the Social Channels documentation, and a sample of (php) usage in the official blog post about Upgrade to Requests 2.0.
I hope that this is what you're looking for.
Edit
When you send the request you know who is sending it right? It's the logged in user, and so you can put the user id/name/etc in the data parameter of the request.
Then, when someone clicks on a request, get the request by the id that facebook passes to you, and from the data extract the user id of the sender.
As the documentation states, you have 255 characters to use, and with that you can do what ever you want, you can even serialize an object to that parameter and deserialize it later.
As it turns out, this is in fact not possible at all.
The link, as shown in the image below, can present multiple users:
which is why multiple request IDs are passed in, and the sender's ID isn't.

Facebook Fan Page vs. Twitter Streaming API

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