Facebook Graph API subscribing to user threads - facebook-graph-api

I'm trying to receive realtime updates of user threads via graph api(2.x), and I work around with Graph API Explore posting a request like below to make a subscription;
https://graph.facebook.com/v2.1/MY_FB_ID/subscriptions
# with these params
access_token: MY_VALID_ACCESS_TOKEN
object: user
fields: threads
verify_token: foo-bar
callback_url: http://example.com/callbacks
then I get this error:
{
"error": {
"message": "(#100) Application cannot subscribe to notifications",
"type": "OAuthException",
"code": 100
}
}
And when I change threads with name, for example, it returns this response.
{
"error": {
"message": "(#2201) response does not match challenge, expected value = '1872122487', received='<!doctype html>\n<htm...'",
"type": "OAuthException",
"code": 2201
}
}
I think this error is good because Facebook API accepts a request and try to verify the server to send notifications exists and setup correctly, but the first one is not good apparently.
So what's odd is both threads and name are listed as valid fields for user object on the document, but only threads is not accepted.
https://developers.facebook.com/docs/graph-api/real-time-updates/v2.0#subscribefields
Any idea about what is wrong with this. I should not do this on explore? Or it's not even possible to subscribe user threads via graph api?
Thanks in advance.

I found we cannot receive realtime updates of user/threads unless being whitelisted by facebook, at least for now.

Related

(#100) Tried accessing nonexisting field (messages) on node type (User)

When I try to get the Messages sent to my Facebook Page, which is linked to Messenger chatbot I get the following error:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (messages) on node type (User)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "A5W_BFDXx9GgriZb697u5zv
"
}
}
Here is also an image of the output:
The Access Token is valid for sure. I have tested below:
Note that the Page is neither Business Verified, not Individual verified. I don't know if this plays a role. However, even though the Page Access Token seems correct, I can't run the GET query.
Update - Use Page Access Token
https://developers.facebook.com/docs/graph-api/reference/page/ doesn’t mention the messages edge any more, but how to use it to send messages, is explained as part of the Messenger API documentation:
https://developers.facebook.com/docs/messenger-platform/reference/send-api/
So, /me/messages is the correct endpoint for that, to be used with a page access token. And since sending messages is a “creating” action, it needs to be a POST request.
Be aware though that you can not just arbitrarily send messages whenever and to whomever you want - usually, the user needs to make contact with your page first, so that your bot can then respond to that. The details of the different types of messaging, and their restrictions, are explained unter https://developers.facebook.com/docs/messenger-platform/send-messages

Facebook ids_for_pages returns "An owning business is required"

I am trying to connect 2 scoped ids of the same user from Messenger and private_replies API call.
When I call ids_for_pages with the private_replies senderId I get this response:
{
"error": {
"message": "(#100) An owning business is required for this request",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "C1wGrChj+O3"
}
}
Any idea what this means?
Maybe this is a bit old, but I faced the same problem today because the error is not clear at all. To solve this, you need to be sure that your page and app are linked or "owned" by the same business, to do that you must go to the business manager:
https://developers.facebook.com/docs/apps/business-manager#update-business

Failed to get message attachments and shares from facebook

I am using facebook graph api to get user message
I try to get shares object from messages sent between two users.
According to Facebook documentation I should use the method /{message-id}/shares https://developers.facebook.com/docs/graph-api/reference/v2.2/message/shares
But when I tried this with a user with read_mailbox permission I get the following error:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
so what I have to do to get shares and attachments
thanx in advanced

Calling Ads API reachestimate returns "Application does not have permission for this action"

Following the Ads API docs for reachestimate (http://developers.facebook.com/docs/reference/ads-api/reachestimate/), I received a "false" response when calling
https://graph.facebook.com/act_0000000000000000/reachestimate?currency=EUR&targeting_spec={'countries':['US']}&access_token=___
(Note: act_0000000000000000 is my user Id and _ is my access token - these tokens work correctly for other Ads API calls).
Using the Graph API Explorer tool, I receive the following response on this API call
{
"error": {
"message": "(#10) Application does not have permission for this action",
"type": "OAuthException",
"code": 10
}
}
However, when I call
https://graph.facebook.com/1111111111111111/reachestimate?currency=EUR&targeting_spec={'countries':['US']}&access_token=___
where 1111111111111111 is an adgroup, I get a valid data structure.
Has anyone come across this elsewhere? Is there a "magic" setting somewhere that enables this capability on the user account (enabled for ads_management, offline_access)?
Any thoughts very welcome.
Thank you.
Thanks #Igy - just confirmed that my issue was indeed the misuse of my UserID in account field - have since migrated these queries to use the designated account ID and works as expected.

Graph API not responding

I am using graph API to get the feed post.
https://graph.facebook.com/128172073865656/feed?limit=200
but it is showing exception
{
"error": {
"type": "OAuthException",
"message": "An access token is required to request this resource."
}
}.
Could any one please help.
Quite simply, you need to obtain and supply an access token with your request.
In particular, the Graph API connections that you're trying to load have been changed recently, and now require an access_token, where they previously did not.
See the Facebook Developer Blog, posts on this:
https://developers.facebook.com/blog/post/509/ - Notification of change in requirements.
https://developers.facebook.com/blog/post/510/ - Confirmation that the changes are now live.