2015-09-05 114 views
0

我想從JavaScript發佈到Facebook頁面源(就好像它是從頁面發佈的)。我登錄OK,但是當我嘗試後,它給出了錯誤Facebook圖形API - (#200)頁面上的權限錯誤發佈

"error: Object code: 200 message: "(#200) Permissions error" type: "OAuthException"

在登錄中,auth響應來通過與下面的權限,我相信有足夠 -

"email,contact_email,manage_pages,publish_pages,publish_actions,public_profile"."

如何我可以得到這個工作嗎?

主要部件(plunk):

function postToMembers(){ 

    var access_token1 = FB.getAuthResponse()['accessToken']; 

    var body = 'Post from code test'; 
    FB.api('/41622-PAGEID-34/feed', 'post', { message: body, access_token: access_token1 }, function(response) { 
     if (!response || response.error) { 
     console.log(response); 
     } else { 
     alert('Post ID: ' + response.id); 
     } 
    }); 

}; 


function loginAndPost(){ 
    FB.login(function(response) { 
     if (response.authResponse) { 
     //Log auth permissions (in the response) 
     console.log(response); 
     FB.api('/me', function(response) { 
      console.log('Successful login for: ' + response.name); 
      document.getElementById('status').innerHTML = 
      'Thanks for logging in, ' + response.name + '!'; 
     }); 

     postToMembers(); 

     } else { 
     console.log('User cancelled login or did not fully authorize.'); 
     } 
    }, {scope: 'publish_actions,publish_pages,manage_pages', return_scopes: true}); 
}; 

有關的信息,我已經看了看文檔hereherehere許多StackOverflow的職位,但不能讓它去。

回答

1

沒有稱爲「contact_email」的權限,只有「email」。

這就是說,你需要一個Page Token來張貼「作爲頁面」。使用/me/accounts獲取頁面的頁面令牌。權限錯誤最有可能意味着您沒有適當的權限,無法使用您的訪問令牌發佈到網頁上。確保它是您管理的網頁,並確保訪問令牌包含publish_pages權限。您可以在調試器中調試您的Access令牌:https://developers.facebook.com/tools/debug/

此外,請確保您嘗試使用應用管理員。未經審覈,這些附加權限僅適用於在應用中擁有角色的用戶。在文檔中查看關於登錄審查的信​​息:https://developers.facebook.com/docs/facebook-login/review