I've been using the PHP SDK to post to a Facebook page of mine for two years. Today I was greeted with this error:
(#200) Requires either publish_to_groups permission and app being installed in the group, or manage_pages and publish_pages as an admin with sufficient administrative permission
I haven't changed anything, and as far as I remember, those permissions were not required when I need to post only to the page I own.
I use PHP SDK v.5.5.0. Here's my code:
$fb = new Facebook\Facebook([
'app_id' => 'MY_APP_ID',
'app_secret' => 'MY_APP_SECRET',
'default_graph_version' => 'v2.9',
'default_access_token' => 'MY_NEVER_EXPIRING_TOKEN'
]);
$linkData = [
'link' => 'http://example.com',
'message' => 'Message',
'description' => 'Description',
'caption' => "Caption",
];
try {
$response = $fb->post('/MY_PAGE_ID/feed', $linkData);
$graphNode = $response->getGraphNode();
echo 'Posted with id: ' . $graphNode['id'];
$status = 1;
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getRawResponse() .
$status = -1;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage() .
$status = -1;
}
Any ideas what could have broken, without me changing anything in the code? Thanks a lot.
It was a bug, reported here: https://developers.facebook.com/bugs/331730207440499/ and quickly fixed by Facebook. Some permissions seem to have been revoked by mistake, and were later restored.