Facebook Real-time updates not working - facebook

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.

Related

Facebook API: (#100) No matching user found

I spent whole days to try to figure out this error, I also notice there are similar questions with the same message, but I'm totally not sure I find the answer in there, so if someone could point out or give any tip into my problem, I totally appreciate that.
I'm making the request to send a message from a Facebook page A to a user X (by userId) who makes a comment on a post of FB Page A, through a testing FB App name MyApp. I am trying this on Facebook Graph Explorer.
I got the user Id by fetch the list of comments in a post in the Facebook Page, but I totally could not send the message.
Here is the error
{
"error": {
"message": "(#100) No matching user found",
"type": "OAuthException",
"code": 100,
"error_subcode": 2018001,
"fbtrace_id": "H3yMO0RWaDy"
}
}
Here is the my track
MyApp has been setup webhook OK, because it is not published yet for the testing purpose (unapproved app), so I have to add the user X account into tester pool of MyApp (the message that I try to send is also this user X)
I logged into user X to make a comment on a post in the FB Page A
On Graph Explorer, I selected Application: MyApp, and get Page Access Token of FB Page A, I performed two following requests
3.1 /{page_id}_{post_id}?fields=comments
With this, I can get the list of existing comments in FB Page A, here is the output:
{
"comments": {
"data": [
{
"created_time": "...",
"from": {
"name": "User X",
"id": "123456789" // this is the user Id that I would take to send the message to
},
"message": "Sample comment from User X",
"id": "..." // {page_id}_{post_id}
}
],
"paging": {
....
}
},
"id": "..." // {page_id}_{post_id
}
}
3.2 {page_id}/messages: I am trying to send a message from FB Page A to user X with the user Id that I got from 3.1 step
recipient: {id: "123456789"} // there seems be a problem with this id that I got from step 3.1, FB cannot find the user id with this number
message: {text: "hello"}
I'm also acknowledged about the app/page scoped id for user.
I have already subscribed MyApp to the FB Page A with API (/{page_id}/subscribed_apps)
Facebook API v2.10
I have no clue what's wrong.
I figured it out. Facebook Messenger Platform use paged scope user id, but what I were using is app scope id. They are different.
Here is official doc from Facebook about how to get the paged scope id
The id must be an ID that was retrieved through the Messenger entry
points or through the Messenger webhooks (e.g., a person may discover
your business in Messenger and start a conversation from there.
These IDs are page-scoped IDs (PSID). This means that the IDs are
unique for a given page.
If you have an existing Facebook Login integration, user IDs are
app-scoped and will not work with the Messenger platform.
The solution is subscribing MyApp to the FB Page (what I've already done) to get the webhook to work, where I will get the page scope id from the message of user.
Furthermore, detail of how to setup the subscription found here
http://ukimiawz.github.io/facebook/2015/08/12/webhook-facebook-subscriptions/

Create a photo album on Facebook through the Graph API

I am trying to create a FB photo album, so that I can use that album in a FB AD. I am using the following request on fiddler:
POST https://graph.facebook.com/v2.5/{page_id}/albums
and I pass the page access token in the body of the request. I keep getting this reply:
{"error":{"message":"(#200) Requires extended permission: manage_pages and publish_pages","type":"OAuthException","code":200,"fbtrace_id":"FCspsWIecMV"}}
After a lot of research, I found this video: https://www.youtube.com/watch?v=vZ28bjBNk6I
This video shows how to give extended permissions, which seems to be the problem, but it is not working properly. I used the following query to give the necessary permission to myself:
https://graph.facebook.com/oauth/authorize?client_id={ap_id}&redirect_uri={our_page}&scope=publish_pages
But it only redirects me to the 'our_page' link. But the first time I have used this link, with "manage_pages" in the scope, it actually has shown me the page in which I had to allow this permission. So I guess the query is correct, because by querying the /me/permissions I get this:
{
"data": [
{
"permission": "manage_pages",
"status": "granted"
},
{
"permission": "public_profile",
"status": "granted"
}
]
}
Any tip on how I can get this done?
I found out that, by selecting the app in the https://developers.facebook.com/tools/explorer, the necessary permissions are then shown for the specific request. After clicking there, all my requests started to work, so it seems that this method is permanent. Below there's an illustrative screenshot of how to do it.

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 Realtime Updates for Payments callback POST received but still having issues

I am using Facebook payments and Realtime Updates for Payments. Here is a typical payment callback from Facebook servers when someone buys/refunds something:
{
"object": "payments",
"entry": [
{
"id": "296989303750203",
"time": 1347996346,
"changed_fields": [
"actions"
]
}
]
}
I am using PHP to get this like this:
$updates = json_decode(file_get_contents("php://input"), true);
It works ok and I got the id stored in $myid. My problem is:
In the same PHP page I try to get details of this ID but it doesn't work:
$getDetails = json_decode(file_get_contents('https://graph.facebook.com/'.$myid.'?access_token='.$app_token));
The response is empty, nothing there. I even tried to get the user with this $user = $facebook->getUser(); in this PHP but it returned with zero. I suspect that since this PHP is run from the Facebook server (and not the client browser) Facebook does not know who the user is and that is why the Graph API does not work.
How can this PHP page knows who the user is? Cookies and sessions cannot be used since they will never communicate with the client browser. Help is needed. Thanks.

Posts from Instagram not showing up on Facebook Open Graph API

I have an issue with Facebook OpenGraph API. Whenever I request data using either '/home' or '/feed', none of the posts from Instagram showed up.
I've been googling around and apparently some people raised the same issue with no solution yet. And I read some that the issue not only affecting posts from Instagram, but also other third-party app/device/platform.
Even the ticket posted on Facebook's dev page seems somewhat dead (no continuation). Link: https://developers.facebook.com/bugs/110563582419837/
If any of you guys also stumbled on this issue and has some ideas/pointers/links, please do share and let's discuss it.
Much appreciated. Cheers!
There are two bug reports in Facebook's bug tracker about this:
https://developers.facebook.com/bugs/110563582419837 and https://developers.facebook.com/bugs/202119973248747
The core reason is that the photos are attached to Open Graph actions as User Generated Photos and not via the regular Photo upload API.
As such, the regular photos permissions don't grant access to them and you need the user to specifically allow you the access their Open Graph activity for the app that posted the actions. The bug reports above are accepted on the basis that this appears to be an oversight in the case of actions with user generated photos, but it could also be by design in which case what i've outlined below as a workaround would be the only supported way to do this:
If you specifically need to request Instagram (or another Open Graph photos app) photos for a user, you can ask for Permission to access the actions posted by that app.
For Instagram photos you can do this by requesting the user_actions:instapp permission and once you've done that the Instagram Photos album will no longer appear to be empty, and the Instagram activity will appear in the feed connection.
To find out the namespace for an arbitrary app, access https://graph.facebook.com/<APP ID> and look for the namespace field,
e.g. for instagram, a call to https://graph.facebook.com/124024574287414/?fields=id,namespace returns:
{
"id": "124024574287414",
"namespace": "instapp"
}
A sample photo from my own /feed connection, retrieved with the read_stream, user_photos, user_actions:instapp permissions, is:
{
"data": [
{
"id": "[SNIPPED]",
"from": {
"name": "[SNIPPED]",
"id": "[SNIPPED]"
},
"picture": "[SNIPPED]",
"link": "https://www.facebook.com/photo.php?fbid=[SNIPPED]",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yb/x/StEh3RhPvjk.gif",
"privacy": {
"value": ""
},
"type": "photo",
"object_id": "[SNIPPED]",
"application": {
"name": "Instagram",
"namespace": "instapp",
"id": "124024574287414"
},
"created_time": "2013-01-07T17:33:04+0000",
"updated_time": "2013-01-07T17:33:04+0000",
"comments": {
"count": 0
}
},
I can also access the /photos connection of my 'Instagram Photos' album with the same permissions, and can access all Instagram 'take' actions (i.e the photos) at /me/instapp:take
Facebook employee here. Looking at the internal task that is tracking this issue, all I can say at this time is that this is an issue that we are currently aware and investigating into. If you would like to be notified of any updates, be sure to click "subscribe" on the bug report.
For the time being, I recommend finding the album ID of the user named "Instagram Photos", then calling a GET request to /INSTAGRAM_ALBUM_ID/photos to get their Instagram photos. On the Graph API Explorer tool, I confirm that I am able to fetch all of my instagram pictures. Since my album is public, you should be able to view them as well.