如何解决“(#200)用户尚未授权应用程序执行此操作".在facebook wal上发布时出错 [英] How to fix "(#200) The user hasn't authorized the application to perform this action" error while posting on facebook wal
问题描述
在用户的Facebook墙上张贴消息时,出现(#200)用户未授权应用程序执行此操作"错误.我正在使用facebook graph API.我还在范围内设置了"publish_actions"权限,但没有起作用.我的代码是
I am getting "(#200) The user hasn't authorized the application to perform this action" error when posting message on user's facebook wall. I am using facebook graph API. I have also set the "publish_actions" permission in the scope, but didn't working. My code is
require 'facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
));
$user = $facebook->getUser();
if ($user) {
$accessToken = $facebook->getAccessToken();
try {
//create message with token gained before
$post = array(
'access_token' => $accessToken,
'message' => 'Test message'
);
$res = $facebook->api('/me/feed', 'POST', $post);
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
} else {
# There's no active session, let's generate one
$login_url = $facebook->getLoginUrl(array(
'scope' => 'publish_actions'
));
header("Location: " . $login_url);
}
您能建议我代码或应用程序中缺少的内容吗?
Can you please suggest me what i am missing in the code or in the app?
推荐答案
由于您提到它确实适用于Admins,但不适用于其他任何人,所以很清楚问题出在哪里:您需要进行Login Review使用 publish_actions
-否则,该权限仅对在应用程序中具有角色的用户有效.
Since you mentioned that it does work for Admins, but not for anyone else, it´s very clear what the problem is: You need to go through Login Review with publish_actions
- else, that permission will only work for users with a role in the App.
您需要有关登录审阅的所有信息在文档中: https://developers.facebook.com/docs/facebook-login/review
All the information you need about Login Review is in the docs: https://developers.facebook.com/docs/facebook-login/review
这篇关于如何解决“(#200)用户尚未授权应用程序执行此操作".在facebook wal上发布时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!