How to overcome the newly arised #200 error while posting to my Facebook page programatically?

て烟熏妆下的殇ゞ 提交于 2019-12-11 14:42:29

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/54545282/how-to-overcome-the-newly-arised-200-error-while-posting-to-my-facebook-page-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!