1

I am able to get the user's access token and pass it to the post_to_page function. It returns the following error:

Object {message: "(#200) Insufficient permission to post to target on behalf of the viewer", type: "OAuthException", code: 200}

I know the app_id is fine, I set the scope of permissions to be: email,user_likes,publish_actions,publish_stream. Is there a permission I am missing to post on behalf of the viewer?

I feel like I missing one thing.

$('a.post-to-page').click(function(event) {

     FB.login(function(response) {
       if (response.authResponse) {
         console.log('Welcome!  Fetching your information.... ');
         FB.api('/me', function(response) {
           console.log('Good to see you, ' + response.name + '.');
           console.log(response);

         });
       } else {
         console.log('User cancelled login or did not fully authorize.');
       }
     }, {scope: 'email,user_likes,publish_actions,publish_stream'});

     FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
        console.log(response.authResponse.accessToken);

        post_to_page(response.authResponse.accessToken);
      }
    });

});

function post_to_page(access_token_data)
{
    var body = 'Reading JS SDK documentation';

    FB.api('/page_id/feed', 'post', { message: body, access_token: access_token_data }, function(response) {
      if (!response || response.error) {
          console.log(response.error);
      } else {
        console.log(response.id);
      }

    });
}
Brad
  • 12,054
  • 44
  • 118
  • 187
  • Where are you trying to post? Is the current user allowed to post there? (i.e are they a fan of the page, does the page allow fans to post, etc?) – Igy May 05 '14 at 22:25

0 Answers0