2013-10-13 41 views
0

我遵循一個與Facebook連接的導師,該導師使用以下代碼成功連接到Facebook。我如何獲得Facebook上的publish_actions權限

的代碼如下 -

FB.Event.subscribe('auth.authResponseChange', function (response) { 
       if (response.status === 'connected') { 
        // the user is logged in and has authenticated your 
        // app, and response.authResponse supplies 
        // the user's ID, a valid access token, a signed 
        // request, and the time the access token 
        // and signed request each expire 
        var uid = response.authResponse.userID; 
        var accessToken = response.authResponse.accessToken; 

        // TODO: Handle the access token 

        // Do a post to the server to finish the logon 
        // This is a form post since we don't want to use AJAX 
        var form = document.createElement("form"); 
        form.setAttribute("method", 'post'); 
        form.setAttribute("action", 'loadMainPage.ashx'); 

        var field = document.createElement("input"); 
        field.setAttribute("type", "hidden"); 
        field.setAttribute("name", 'accessToken'); 
        field.setAttribute("value", accessToken); 
        form.appendChild(field); 

        document.body.appendChild(form); 
        form.submit(); 

       } else if (response.status === 'not_authorized') { 
        // the user is logged in to Facebook, 
        // but has not authenticated your app 
       } else { 
        // the user isn't logged in to Facebook. 
       } 
      }); 

     }; 

我怎麼能要求publish_actions許可?

回答

0

您使用的平臺是什麼?見Facebook's official docs

的摘錄:

請求權限

每種類型的登錄流程都有自己的請求這些權限的方法:

  • Web登錄使用JavaScript SDK使用範圍選項與FB.login函數調用。
  • 其他類型的網絡登錄應該將範圍參數添加到它們重定向到的對話URL的登錄 。
  • Android登錄在LoginButton類中使用setReadPermissions和setPublishPermissions 。
  • iOS登錄使用FBLoginView類中的readPermissions和publishPermissions屬性 。
相關問題