Gipsy King
Gipsy King

Reputation: 1577

Post from facebook app to (fan) page - application has not enough permissions

I have a facebook application, and a facebook (fan) page. I want to publish to the page, authentified as the app (if possible), from a php script run periodically as a cron job.

I'm using the official facebook php sdk.

I am trying to post to the page with $facebook->api($pageId."/feed", 'POST', $post);, where $post contains the required message and link keys, and should also contain access_token.

To get the access token, I tried using $facebook->getApplicationAccessToken(), and making a curl request to https://graph.facebook.com/oauth/access_token (same result).

The response I get is: OAuthException: (#200): The user hasn't authorized the application to perform this action

I was able to post to the page, but with an access_token from https://graph.facebook.com/me/accounts, which required me to provide a user's access token in the first place. The user's and and his page's tokens seem to expire, at most after 60 days, so this solution is not good.

I tried granting permissions like explained here Authorizing a Facebook Fan Page for Status Updates, but I still get the error from before.

Any solution on how to post to a facebook page which does not involve user login will be welcome!

Upvotes: 0

Views: 2149

Answers (2)

anand
anand

Reputation: 705

You can get the required access_token for posting to a facebook page via an application using the Graph API Explorer. In the Explorer:

  1. Select the application on behalf of which you want to to do things(post,like, etc.).
  2. Enter the url for the page: https://graph.facebook.com/page' in the url field.
  3. Click "Get Access Token to get it.
  4. You willl get a dialog box; select the permissions to grant to this app.; atleast publish_stream, offline_access & manage_pages( for posting to page wall post)
  5. You will get a new access token that you can use with your app. to post to your page.

Upvotes: 1

Juicy Scripter
Juicy Scripter

Reputation: 25938

It is not possible to post on Page using Application access_token and without logging user in (at least once to get an access_token, later it can be extended) and requesting appropriate permissions.

To publish to Page as User you need publish_stream permission granted by User.

To publish to Page as Page you need publish_stream and manage_pages permissions granted by User and Page access_token which can be retrieved from accounts connection of user.

Upvotes: 3

Related Questions