Graph API not responding - facebook-graph-api

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.

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

What permissions are needed to call /{page-id}/ads_posts on Facebook Graph API?

I'm trying to list the Ads for a Facebook Page using the Graph API /{page-id}/ads_posts endpoint, but I get a permissions when I try to.
Using the Graph API Explorer, I generate an Page Access Token with those permissions: email, read_insights, manages_pages, pages_show_list, ads_read, business_management, instagram_basic, instagram_manage_insights and public_profile.
I'm an admin on the Page itself, the attached Business Manager and on the corresponding Ad Account.
Every time I try to call the /{page-id}/ads_posts, I receive
{
"error": {
"message": "(#200) Not enough permission to call this endpoint",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "XXXXX"
}
}
I can't find any help on the Facebook documentation or Google, given that the error isn't really meaningful (in some cases, I get a message saying that a specific permissions is missing, but not here). Anyone can help ?
EDIT: I tried to add the ads_management permission too, without success.
You need to add those pages to your app that is in development mode (https://www.facebook.com/settings?tab=business_tools).

Facebook Graph API: Ban user function for pages doesn't work

I need to have the ability to ban users in page via API. I use next request:
POST
/page_id/blocked
data: user=user_id
It was working earlier. But now is not working. Currently I get error:
"message": "(#100) Required parameter user was not provided",
"type": "OAuthException",
"code": 100,
The documentation still: https://developers.facebook.com/docs/graph-api/reference/v2.9/page/blocked
How to make it work?
I had to change two things in order to make it work:
As the user ID came from my app, it is considered an 'app-scoped ID' (asid)
For blocking, the expected parameter is an array of IDs
POST 123pageid456/blocked?asid=[123userid456]
I got the same error, and filed a Facebook bug: https://developers.facebook.com/bugs/700023220191487/
It turns out the API does not currently support page-scoped IDs from the messenger platform. Only page IDs for the Facebook page.

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.

Facebook Post to wall from

I've a facebook application and a group for that application. Is it possible to make the application automatically post on the group. As far as posting is concern, its ok but how to give the application permission to post on the group?
I'm using facebook graph explorer to test this
https://graph.facebook.com/GROUP_ID/feed, method Post and adding a field 'link' with URL 'http://www.google.com' and selecting application as the application i want. I'm getting this error:
{
"error": {
"message": "An unexpected error has occurred. Please retry your request later.",
"type": "OAuthException",
"code": 2
}
}
The error doesn’t exactly say this, but I’d guess it’s thrown because your not sending a valid access token.
Get a user access token from one of the users that is allowed to post to that group’s wall.
The problem was a permission problem and the permission needed was user_groups,publish_stream