FB.login()没有要求给定的权限

Chr*_*ris 5 javascript facebook

登录正在运行,但它只询问基本权限,并且在取消或完成对话时没有触发警报.

 window.fbAsyncInit = function() {

    // init the FB JS SDK
    FB.init({
      appId      : 'XXX', // App ID from the App Dashboard
      channelUrl : 'XXX', // Channel File for x-domain communication
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : true,  // parse XFBML tags on this page?
      frictionlessRequests: true,
      oauth: true
    });

     FB.login(function(response) {
       if (response.authResponse) {
         alert("ok");
       } else {
        alert("canceled");
       }
     }, {scope:'publish_actions,publish_stream'});

  };
Run Code Online (Sandbox Code Playgroud)

CMH*_*CMH 9

你在用fb:login-button吗?如果是这样,您是否尝试过在那里添加权限而不是FB.login()?所以它看起来像:

<fb:login-button scope="publish_actions,publish_stream"></fb:login-button>
Run Code Online (Sandbox Code Playgroud)

  • 这个答案应该标记为正确的答案.这解决了我的问题.使用`fb:login-button`时,方法`FB.Login`不发送`scope`参数.这似乎是一个facebook库的bug. (2认同)