我该怎么做才能解决这个问题这是我的代码我正在使用脸谱图API来做到这一点 require_once(" SRC / facebook.php&#34); //设置正确的路径
$config = array();
$config['appId'] = '000000000000000';
$config['secret'] = '0000000000000000000000';
$config['fileUpload'] = false; // optional
// $config['publish_actions'] = true;
$fb = new Facebook($config);
$params = array(
// this is the access token for Fan Page
"access_token" => "--------------------- my access token --------------------------",
"message" => "Here is a blog post about auto posting on Facebook using PHP #php #facebook",
"link" => "http://www.pontikis.net/blog/auto_post_on_facebook_with_php",
"picture" => "http://i.imgur.com/lHkOsiH.png ",
"name" => "How to Auto Post on Facebook with PHP",
"caption" => "www.pontikis.net",
"description" => "Automatically post on Facebook with PHP using Facebook PHP SDK. How to create a Facebook app. Obtain and extend Facebook access tokens. Cron automation."
);
try {
// 466400200079875 is Facebook id of Fan page https://www.facebook.com/pontikis.net
$ret = $fb->api('/417648154966881/feed', 'POST', $params);
echo 'Successfully posted to Facebook Fan Page';
} catch(Exception $e) {
echo $e->getMessage();
}
答案 0 :(得分:0)
我有来自用户请求权限的代码...我希望这有帮助。您使用旧版本的facebook api,我会尽快更新偏好
require 'src/facebook.php';
$config = array('appId' => '000000', 'secret' => '000000', );
$facebook = new Facebook($config);
try
{
$user_id = $facebook -> getUser();
if($user_id){
$user_profile = $facebook->api('/me','GET');
}else {
$login_Url = $facebook -> getLoginUrl(array('canvas' => 1, 'fbconnect' => 0, 'scope' => 'user_about_me,user_activities,user_status,read_stream,publish_stream,photo_upload,status_update,publish_actions','redirect_uri' => 'https://yoururl.com/'));
exit("<script>window.top.location.replace('$login_Url');</script>");
}
}catch(exception $e){
/
exit("<script>location.reload();</script>");
}
更新
网址偏好:https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/
答案 1 :(得分:0)
错误消息表示您没有使用publish_actions
权限授权用户,或者您根本没有授权用户。
关于授权,请在Facebook文档中查看此页面:https://developers.facebook.com/docs/php/gettingstarted/4.0.0
请记住,您需要一个“页面访问令牌”来发布“as Page”,这在以下文章中得到了很好的解释:
基本上,您需要使用publish_actions
和manage_pages
授权用户,并使用API调用/me/accounts
以获取所有网页的页面标记用户。
...然后有“Login Review”。这些权限仅适用于在App(Admin / Developer / Tester)中具有角色的用户。在向公众发布应用程序之前,您需要与他们一起完成审核流程。
当然,你必须自己做编程部分。虽然不是那么难:)。