我试图从近4-6小时制作这个剧本,但没有运气。我有一个Facebook页面,Facebook应用程序和Facebook帐户。我想以一种方式编写代码,它应该能够在我的Facebook页面上发布而无需任何人工干预。我使用下面的代码
require_once("application/libraries/facebook-php-sdk-master/src/facebook.php");
// initialize Facebook class using your own Facebook App credentials
// see: https://developers.facebook.com/docs/php/gettingstarted/#install
$config = array();
$config['appId'] = '{appid}';
$config['secret'] = '{appsecret}';
$config['fileUpload'] = false; // optional
$fb = new Facebook($config);
// define your POST parameters (replace with your own values)
$params = array(
"access_token" => "{token}",
"message" => "Here is a blog post about auto posting on Facebook using PHP #php #facebook"
);
try {
$ret = $fb->api('/mypagename/feed', 'POST', $params);
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
使用"用户访问令牌"在API资源管理器中,我可以发布到fb页面,但作为"访客"不是管理员,如果我使用" App令牌"我收到错误消息
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "Bk30JLt+skw"
}
}
如何添加发布到我自己的Facebook墙的权限,是否可能?