0
votes

I am writing a simple JS program to post on FB.

The login script looks something like below:

indow.fbAsyncInit = function() {
  FB.init({
    appId: '1469527639#######',
    version    : 'v2.0',
  xfbml      : true,
  status     : true,
  cookie    : true
  });

  // fetch the status on load
  FB.getLoginStatus(loginChecker);

};



(function(d, s, id){
  var js; 
  var fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}

  js = d.createElement(s); 
  js.id = id;

  js.src = "//connect.facebook.net/en_US/sdk.js";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

function loginChecker(response){

    if(response.status === "connected"){
      console.log('This app is already authorized');
      } else if(response.status === "not_authorized") {
      console.log('This app is not authorized');
      } else {
      console.log('user is not logged into fb');
      FB.login(function(){}, { scope: 'publish_actions',  return_scopes: true});
    }
}

The above script doesn't exactly perform as per expectation. It does display the Facebook login box, however after I enter my credentials, it does not ask for permission to post on wall.

I have another function that is suppose to post a message on the user's wall once the user is logged in. But since the above script does not ask for these permissions, i am unable to post.

As per Facebook documentation, i should be asking for permissions using

{ scope: 'publish_actions',  return_scopes: true}

I am already doing this.

The button that posts on the user's wall is simple :

$('#postit').bind('click', function(){ var messageToPost = document.getElementById("messageArea").value;

FB.api('/me/feed','post',{message: messageToPost},function(response){
  if(!response || response.error){
    console.log('There was a issue in posting your emssage');
    } else {
    console.log(response.id);  
  }
});

});

1
are you trying with an app admin or with another user? - luschn
tried it with both.. the admin and another user. Also have set the app permission to "available to general public" so i believe this should not be a issue.. - runtimeZero
it will not work with another user if the permission is not approved by facebook, that´s why i am asking. - luschn
try with an app admin and check if the permission is really not there - luschn
well, weird....it´s too late for me to try that code, but it does look alright. btw, a side note about that: "post a message on the user's wall once the user is logged in" - if you want to autopost something on the user wall after login, please don´t. it´s spam, and you will not get publish_actions approved for this anyway. also, make sure the message parameter is always 100% user generated, and every feed post is specifically authorized by the user. - luschn

1 Answers

0
votes

Most permissions need to get approved by Facebook before they can be used by Users. Without approval, they only work for App Admins and other Users will only get basic permissions in the login process. See the change log and review guidelines for more information:

Btw, make sure the message parameter is always 100% user generated, or you will definitely not get through the review process with publish_actions.