0

我正在使用javascript sdk,並且我已發送審查我的publish_action,它們已被批准。反正我不能發佈我的帖子,我需要範圍的方式是這樣的:Facebook Js Sdk,publish_actions不起作用

FB.login(function(response) 
{ 
... 
}, {scope: 'email,publish_actions'}); 

當我嘗試發佈返回錯誤是:

(#200) The user hasn't authorized the application to perform this action 

這是真的,因爲在Facebook的模式登錄,只出現讀取配置文件信息的權限,沒有發佈權限。我能如何解決?

編輯

添加我的完整代碼,以更好地解釋:

<script type="text/javascript"> 


/***FACEBOOK***/ 


    function fb_publish_Photo(immaginelink,idfoto){ 
      var testo_share= $("#share_text").text(); 


      var wallPost = { 
       message: testo_share, 
       link:immaginelink, 
       picture:immaginelink 

       }; 
       console.log(wallPost); 
       FB.api('/me/feed', 'post', wallPost , function(response) { 
       if (!response || response.error) { 

        console.log(response.error); 
        alert('Failure! ' + response.error + ' You may logout once and try again'); 


       } else { 
       // alert('Success! Post ID: ' + response.id); 
        var PostId=response.id; 
        if(response.id!=null && response.id!=''){ 

        FB.getLoginStatus(function (response) { 
         if (response.authResponse) { 



         } else { 
          // do something...maybe show a login prompt 
         } 
        }, {scope: 'publish_actions'}); 
        } 
       } 
       console.log(response); 
       }, { scope: 'publish_actions'}); 
    } 

    function statusChangeCallback(response) { 
     console.log('statusChangeCallback'); 
     console.log(response); 
     // The response object is returned with a status field that lets the 
     // app know the current login status of the person. 
     // Full docs on the response object can be found in the documentation 
     // for FB.getLoginStatus(). 
     if (response.status === 'connected') { 
      // Logged into your app and Facebook. 
      //fb_login(); 

     } else if (response.status === 'not_authorized') { 

     } else { 

     } 
     } 

    function fb_login(){ 
     FB.login(function(response) { 

      if (response.authResponse) { 
       console.log('Welcome! Fetching your information.... '); 
       //console.log(response); // dump complete info 
       access_token = response.authResponse.accessToken; //get access token 
       user_id = response.authResponse.userID; //get FB UID 

       FB.api('/me?fields=email,first_name,last_name,name', function(response) { 
        //chiamata ajax per registrare/loggare l'utente 
        console.log(response); 

       }); 

      } else { 
       //user hit cancel button 
       console.log('User cancelled login or did not fully authorize.'); 

      } 
     }, { 
      scope: 'publish_actions' 
     }); 
    } 
     // This function is called when someone finishes with the Login 
     // Button. See the onlogin handler attached to it in the sample 
     // code below. 
     function checkLoginState() { 
     FB.getLoginStatus(function(response) { 
      statusChangeCallback(response); 
     }); 
     } 

     window.fbAsyncInit = function() { 
      FB.init({ 
      appId  : 'xxxxxxxxxxx', 
      cookie  : true, // enable cookies to allow the server to access 
           // the session 
      xfbml  : true, // parse social plugins on this page 
      version : 'v2.4' // use version 2.4 
      }); 

      // Now that we've initialized the JavaScript SDK, we call 
      // FB.getLoginStatus(). This function gets the state of the 
      // person visiting this page and can return one of three states to 
      // the callback you provide. They can be: 
      // 
      // 1. Logged into your app ('connected') 
      // 2. Logged into Facebook, but not your app ('not_authorized') 
      // 3. Not logged into Facebook and can't tell if they are logged into 
      // your app or not. 
      // 
      // These three cases are handled in the callback function. 

      FB.getLoginStatus(function(response) { 
      statusChangeCallback(response); 
      }); 

     }; 

     // Load the SDK asynchronously 
     (function(d, s, id) { 
     var js, fjs = d.getElementsByTagName(s)[0]; 
     if (d.getElementById(id)) return; 
     js = d.createElement(s); js.id = id; 
     js.src = "//connect.facebook.net/en_US/sdk.js"; 
     fjs.parentNode.insertBefore(js, fjs); 
     }(document, 'script', 'facebook-jssdk')); 

    /***end FB***/ 
</script> 

編輯

這是唯一的裁判我能Facebook的文檔中找到:

function myFacebookLogin() { 
    FB.login(function(){}, {scope: 'publish_actions'}); 
} 

FB.login(function(){ 
    // Note: The call will only work if you accept the permission request 
    FB.api('/me/feed', 'post', {message: 'Hello, world!'}); 
}, {scope: 'publish_actions'}); 

看起來很簡單,在登錄調用中我必須要求權限,那麼爲什麼發佈權限對話框不會出現在已批准的應用程序中?

編輯

enter image description here

這是我的應用程序許可的屏幕

+0

您知道只有在登錄對話框的_second_「頁面」上要求發佈權限,對嗎? – CBroe

+0

我在登錄對話框中看不到任何第二個「頁面」。我已經讀過,建議劃分範圍,所以我也嘗試請求只在登錄電子郵件範圍,然後在FB.api只有publish_actions作用域,但任何更改 – user31929

+0

將範圍傳遞給FB.api是完全廢話,我不不知道哪裏的新手總是想出... – CBroe

回答

0

Publish_actions範圍現在看來正常工作。我有兩次範圍要求。