Trying to post to facebook wall with PHP .. getting error message "(#200) User does not have sufficient administrative permission for this action on this page"

The APP ID and secret belong to an administrator .. I don't understand

require_once 'lib/facebook/facebook.php';

$appsecret = 'HIDDEN FOR POSTING TO EE';

//Function to Get Access Token
function get_app_token($appid, $appsecret)
$args = array(
'grant_type' => 'client_credentials',
'client_id' => $appid,
'client_secret' => $appsecret

$ch = curl_init();
$url = '';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);

return json_encode($data);

// Create FB Object Instance
$facebook = new Facebook(array(
    'appId'  => $appid,
    'secret' => $appsecret,
    'cookie' => false,

//Get App Token
$token = rtrim(ltrim(get_app_token($appid, $appsecret), '"access_token='), '"');

//Try to Publish on wall or catch the Facebook exception
try {
$attachment = array('message' => '',
            'access_token' => $token,
                    'name' => 'Name',
                    'caption' => 'Caption',
                    'link' => '',
                    'description' => 'The description...',
                    'picture' => '',
                    'actions' => array(array('name' => 'View', 
                                      'link' => ''))

$result = $facebook->api('/'.$appid.'/feed/', 'post', $attachment);

//If the post is not published, print error details
catch (FacebookApiException $e) {
echo '<pre>';
echo '</pre>';


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Terry WoodsIT GuruCommented:
Whose page is it? You need to be the administrator of the page to be able to post to the news feed, and you need a facebook app set up to do that, with an app id and secret. If you don't have that level of access, you can only submit a post to the "posts to page" section of the page.

I did end up setting up some crude post to page automation, for a specific page, to be done by the page administrator. Took ages to understand what to do and why. At least part of the process needs to be done with the facebook javascript API.
MarkProgrammerAuthor Commented:
It is a personal account with a business page. The administrator credentials were created while logged into a sub-user account (authorized to post in the business page)

I am only trying to post on the business page..
Terry WoodsIT GuruCommented:
This answer is based on work I did about 6 months ago, and is going by memory. I'm assuming it's still up to date (the rules for the Facebook API's have changed multiple times in the past).

To post to the business page, you'll need a facebook app. Through the Facebook App settings there is a relatively formal review process which you must go through if the app is to get general Manage Page permissions. Without going through that process, Manage Page permissions are still available but are limited (perhaps only to pages belonging to the app owner? I can't remember the exact details).

To authenticate sufficiently to post to the business page, you need your program to connect to facebook with the Facebook javascript api, which from memory gives you an access token. You then need to use the Facebook javascript API again to request "Manage page" permissions for the page in question. At that point, you will have permission to post to the page without getting an error 200.

I tried for ages to get PHP to do it, but my conclusion (based on what I eventually found, which was pretty clear) was that it's no longer possible to authenticate with the PHP API; you must use the javascript API to authenticate. Once you've done that, I understand you are able to use ajax to pass the access token to PHP where it can be used, but it may not necessary depending on what you want to do.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarkProgrammerAuthor Commented:
Do you recall if I have to get approval even though the app is not public? We are simply posting to our own Facebook business page but need to do it programmatically
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.