Automatically post on Facebook page wall as app
i am actually working on some legacy PHP code for an e-commerce website where managers can automatically share some products on their shop facebook page. This is not working anymore and, even following the facebook API reference, i'm still in trouble. The legacy code uses an app to posts on the wall
ACCESS TOKEN
In order to get a valid Access token, i make a redirect to:
http://www.facebook.com/dialog/oauth?client_id=$FB_APP_ID&
redirect_uri=$APP_RETURN_URL&
scope=publish_actions,manage_pages
Then, i get the CODE it return and ask a GET request to https://graph.facebook.com/oauth/access_token with following parameters:
'client_id' => $FB_APP_ID,
'redirect_uri' => $APP_RETURN_URL,
'client_secret' => $FB_APP_SECRET,
'code' => $code (got from the above redirect)
Then i store the access token it returns (i get no error messages and a valid access_token)
The problem is that, when i try to post on the wall with a POST call to https://graph.facebook.com/$pageId/feed i get the following error message:
(#283) Requires extended permission: manage_pages
The scope parameters i use for the first redirect are not enough to get the manage_pages permission?
NB i do that with my facebook user account, who is Editor on the facebook page. maybe it helps
EDIT: that's the output of access token debug:
App ID .....
User ID ...
User last installed this app via API v2.x
Issued 1452163781 (21 hours ago)
Expires 1457347781 (in about 2 months)
Valid True
Origin Web
Scopes email, public_profile
how should i ask for manage_pages scope?
You need to get those permissions reviewed by Facebook, before you can ask normal users (users without a role in the app) for those permissions.
This is explicitly mentioned in multiple places in the documentation, and described in broad detail: https://developers.facebook.com/docs/facebook-login/permissions/review
Plus, from API v2.3 on, you need publish_pages
permission (instead of publish_actions
) to post as a page.
上一篇: git init模板,替换修改后的钩子