0

尝试使用 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 throw

有任何想法吗 ?

谢谢!

4

1 回答 1

2

'req_perms' 和 'ext_perms' 是什么?根据文档,权限应位于“范围”参数中 - https://developers.facebook.com/docs/reference/dialogs/oauth/https://developers.facebook.com/docs/authentication/

检查您是否使用过时的示例或教程 - 始终首先检查官方文档

于 2012-05-09T19:56:22.223 回答