2

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!

andyrandy
  • 72,880
  • 8
  • 113
  • 130
Richard Snell
  • 47
  • 1
  • 7
  • debug your page token in the debugger: https://developers.facebook.com/tools/debug/ – andyrandy Dec 02 '15 at 09:20
  • what you need is manage_pages and publish_pages – andyrandy Dec 02 '15 at 09:20
  • I already have both "manage_pages" and "publish_pages" - see the complete list in my post. – Richard Snell Dec 02 '15 at 09:34
  • if I use debug "page token" the list of scopes is: email, manage_pages, publish_actions, public_profile - so this does not have "publish_pages". Is this likely the issue? The app does have "publish_pages" – Richard Snell Dec 02 '15 at 09:37
  • well, that IS the issue. you cannot post without publish_pages. if it does not show up in the debugger, you did not authorize it. see my answer. – andyrandy Dec 02 '15 at 09:39
  • okay. I'm confused. The app does have this permission as it is listed in "Approved Items" - is the scope on the access code something different? And if so how do I add this permission? Sorry, I do not have experience with fb app development – Richard Snell Dec 02 '15 at 09:43
  • there is a big difference between "approved" and "authorized". make sure you understand the difference. did you really get those permissions "approved" in the review process? do you know about login review? – andyrandy Dec 02 '15 at 09:51
  • in any case, your token does not include the publish_pages permission, so create a token that includes it. either with the api explorer or by progamming a login process. see the facebook docs for code examples and information. – andyrandy Dec 02 '15 at 09:52
  • this may help you too: http://www.devils-heaven.com/facebook-access-tokens/ – andyrandy Dec 02 '15 at 09:52

1 Answers1

0

"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.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • Great. Thanks...it now posts without error! It is posting to my user wall instead of the group though...but it looks like I might have the wrong access-code – Richard Snell Dec 02 '15 at 10:55
  • group? i thought we´re talking about a page here, not a group? anyway, the correct endpoint is /page-id/feed with a page token. – andyrandy Dec 02 '15 at 12:10