最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Facebook Graph API - (#200) Permissions error on Page Post - Stack Overflow

programmeradmin3浏览0评论

I want to post to a Facebook Page feed from JavaScript (as if it were from the page). I log in OK, but when i try to post, it gives the error

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

In the login, the auth response es through with the following permissions which i believe are sufficient -

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

How can i get this working please?

Main Parts (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});
};

For info, I have looked at the docs here, here, and here and many StackOverflow posts but can't get it going.

I want to post to a Facebook Page feed from JavaScript (as if it were from the page). I log in OK, but when i try to post, it gives the error

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

In the login, the auth response es through with the following permissions which i believe are sufficient -

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

How can i get this working please?

Main Parts (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});
};

For info, I have looked at the docs here, here, and here and many StackOverflow posts but can't get it going.

Share asked Sep 5, 2015 at 14:39 JJJCoderJJJCoder 17k19 gold badges105 silver badges130 bronze badges 1
  • Check this answer: stackoverflow./a/78798556/15256130, it might be helpful – Obada Jaras Commented Jul 26, 2024 at 14:20
Add a ment  | 

1 Answer 1

Reset to default 2

There is no permission called "contact_email", there is only "email".

That being said, you need a Page Token to post "as Page". Use /me/accounts to get Page Tokens for your Pages. The permission error most likely means that you don´t have the appropriate permissions to post to the Page with your Access Token. Make sure it is a Page you manage, and make sure the Access Token includes the publish_pages permission. You can debug your Access token in the Debugger: https://developers.facebook./tools/debug/

Also, make sure you are trying with an App Admin. Without review, those additional permissions only work for Users with a role in the App. See information about Login Review in the docs: https://developers.facebook./docs/facebook-login/review

发布评论

评论列表(0)

  1. 暂无评论