Search code examples
facebookfacebook-graph-apifacebook-permissionsfacebook-graph-api-v2.3

Unable to post to FB page using Graph API 2.3


I have spent ages trying to get this to work and spent just as long searching forums (including this one) for an answer. Unfortuntely, I can't seem to find any solution to this problem.....

I have created a FB app which is used amongst other things to post (as a page) to a page in FB.

Through dedugging I have the whole URL as:

https://graph.facebook.com/216065898461057/feed?access_token={access-token}

the "access code" is the page access code and I have also included the "page-id" in the URL. I quote the FB documentation:

When a user access token of a Page admin is in the request such as POST /v2.3/{page-id}/feed, the action occurs with the voice of the user, instead of the Page. To publish as the Page, you must now use the Page access token.

Running the code I receive the following error back from FB: "The remote server returned an error: (403) Forbidden."

If I use FB Graph Explorer doing the same thing I get the following error:

{ "error": { "message": "(#200) The user hasn't authorized the application to perform this action", "type": "OAuthException", "code": 200, "fbtrace_id": "GgRkiy/i6tP" } }

Now, many posts will suggest adding necessary permissions to the app but I currently have the following approved:

email, manage_pages, public_profile, publish_actions, publish_pages, user_friends, user_managed_groups

My understanding is that you should only need publish_pages in v2.3.

Can anyone see why this would not be working!


Solution

  • "The user hasn't authorized the application to perform this action" usually means just one thing: Your Access Token is missing the correct permission. In that case, it would be publish_pages. You should definitely have manage_pages, because you need it to get a Page Token. Those are the only two permissions you need to post to the Page "as Page".

    Make sure you authorize the user with publish_pages before getting a Page Token.