我在尝试使用Facebook Graph API自动发布链接时收到错误
我的PHP代码
<?
$config = array();
$config['appId'] = '3545XXXXXXX6207';
$config['secret'] = '60068XXXXXXXXXXXe45a426';
$facebook = new Facebook($config);
$retour_login = json_decode(stripslashes($_GET['session']), true);
$uid = $retour_login['uid'];
$access_token = $retour_login['access_token'];
$me = null;
if ($session) {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
}
}
if(!isset($_GET['session'])) { // Asking permissions
$params = array(
'locale' => 'fr_FR',
'display' => 'popup',
'req_perms' => 'email,user_about_me,user_birthday,user_location',
'ext_perms' => 'publish_stream,share_item,manage_pages'
);
header("Location: ".$facebook->getLoginUrl($params));
}
$args = array(
'message' => "XXXX",
'link' => 'XXXX',
'name' => 'XXXX',
'picture' => 'XXXX',
"caption"=> "lien.com",
"type"=> "link");
$post_id = $facebook->api("/me/links", "post", $args); // execute this to automatically post on FB
?>
我收到此错误:OAuthException:(#282)需要扩展权限:抛出share_item
有什么想法吗?
谢谢!
答案 0 :(得分:2)
那里有'req_perms'和'ext_perms'是什么?根据文档 - https://developers.facebook.com/docs/reference/dialogs/oauth/和https://developers.facebook.com/docs/authentication/
,权限应位于“范围”参数中检查您是否使用过时的示例或教程 - 始终先查看官方文档