[英]php (#200) The user hasn't authorized the application to perform this action
what should i do to fix this problem this is my code i am using facebook graph API to do it require_once("src/facebook.php"); 我应该怎么解决这个问题,这是我的代码,我正在使用facebook graph API来做到这一点require_once(“ src / facebook.php”); // set the right path //设置正确的路径
$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();
}
I have a code with request permission from user... I hope this help.You have use old version with facebook api, I will update preference soon 我有一个具有用户请求权限的代码...希望有帮助。您已将旧版本与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>");
}
update 更新
URL Preference: https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/ URL首选项: https : //developers.facebook.com/docs/reference/php/facebook-getLoginUrl/
The error message means that you did not authorize the user with the publish_actions
permission, or you did not authorize the user at all . 该错误消息表示您未授权用户使用publish_actions
权限,或者您根本没有授权用户 。
About authorization, check out this page in the Facebook docs: https://developers.facebook.com/docs/php/gettingstarted/4.0.0 关于授权,请在Facebook文档中查看以下页面: https : //developers.facebook.com/docs/php/gettingstarted/4.0.0
Keep in mind that you need a "Page Access Token" to post "as Page", this is explained very well in the following articles: 请记住,您需要一个“页面访问令牌”来发布“作为页面”,以下文章对此进行了很好的解释:
Basically, you need to authorize a user with publish_actions
AND manage_pages
and call /me/accounts
with the API to get Page Tokens for all the Pages of the user. 基本上,您需要使用publish_actions
和manage_pages
授权用户,并使用API调用/me/accounts
以获得该用户所有页面的页面令牌。
...and then there is " Login Review " . ...然后有“ 登录评论 ” 。 Those permissions will only work for users with a role in the App (Admin/Developer/Tester). 这些权限仅对在App(Admin / Developer / Tester)中具有角色的用户有效。 You need to go through a review process with them before you can release your App to the public. 您需要先与他们进行审核,然后才能向公众发布您的应用。
Of course you have to do the programming part on your own. 当然,您必须自己完成编程部分。 It´s not that hard though :) 虽然不难:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.