title: To post on facebook page using javascript SDK with page access token
body: <p>I am trying to post to my facebook's wall using javascript SDK. I am first getting user access token. Then using user access token i am getting page access token and including it while posting to a wall. I'm getting following error <a href="https://i.stack.imgur.com/iNHiH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iNHiH.png" alt="enter image description here"></a></p>
  
  <p>here's my code : First am trying to login using FB.login</p>
  
  <pre><code>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 + '.'+JSON.stringify(response));
              });
          } else {
              console.log('User cancelled login or did not fully authorize.');
          }
      },{scope: 'manage_pages,publish_pages'});
  </code></pre>
  
  <p>Then trying to post to a page. </p>
  
  <pre><code>var body = 'Reading JS SDK documentation';
  FB.getLoginStatus(function(response) { 
                 console.log('login status',response);
              if(!(response.status === 'connected')){
                  location.href = './fb-login.html';
                  } else {
                      uID = response.authResponse.userID;
                      accessToken = response.authResponse.accessToken;
                      console.log('accesstoken::',response.authResponse.accessToken);
                      FB.api('/me', {fields: 'last_name'}, {  access_token : accessToken } ,function(response) {
                          console.log(response);
                      });
                      //get list of pages
                      if(accessToken!=null){
                          FB.api('/me/accounts','get',{  access_token : accessToken },function(response){
                              console.log('resp of pages',response);
                              if(response!=null){
                                  var data = response.data;
                                  pageAccessToken= data[0].access_token;
                                  console.log('pageAccessToken::',pageAccessToken);
  
                                  FB.api('/6599048*******/feed', 'post', {message :body, access_token : pageAccessToken }, function(response) {
                                      console.log('response',response)
                                      if (!response || response.error) {
                                          alert('Error occured');
                                      } else {
                                          alert('Post ID: ' + response.id);
                                      }
                                  });
                                  }
  
                          });
                      }
  </code></pre>