我需要获得许可才能以编程方式 post 在我的墙上吗?

Do I need permission to programatically post on my wall?

我想在我拥有的页面上以编程方式 post 一个新故事。我需要向 Facebook 请求许可才能这样做吗?当我调用 Facebook -> post 时出现错误:(#200) The user hasn't authorized the application to perform this action.

我想请求publish_actions权限,但似乎是允许我的应用程序post到应用程序用户的墙,这不是我打算做的,我只是想发布在我自己的墙上。

这是我的代码:

$fb = new Facebook\Facebook([
  'app_id' => 'my app id',
  'app_secret' => 'my app secret',
  'default_graph_version' => 'v2.9',
  'default_access_token' => 'the access token'
  ]);


$linkData = [
  'link' => 'http://example.com/link/for/today',
  'message' => 'This is the link for today',
  ];

try {
  $response = $fb->post('/me/feed', $linkData);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
}

$graphNode = $response->getGraphNode();

echo 'Posted with id: ' . $graphNode['id'];

感谢您的帮助!

要post到页面作为页面,您将需要权限manage_pagespublish_pages,并且您需要获得首先是一个页面访问令牌...然后使用它来创建 post.

https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens