0
votes

I am a newbie in coding. When I called the below function to post on my wall. I always encouunter error occured alert box. I have search the web for few days still cannot find the result and the fix. The facebook documentation is really bad. Please help. I could call fb.ui, or fb.getloginstatus with no problem. But just have problem of calling the fb.api.

function postToWall() {
     var body = 'Reading JS SDK documentation';
     FB.api('/me/feed', 'post', { message: body }, function(response) {
       if (!response || response.error) {
        // alert('Error occured');
       } else {
        // alert('Post ID: ' + response.id);
       }
     });
     FB.api('/me', function(response) {
      // console.log(response);
     });
}

The error message is-

An active access token must be used to query information about the current user.

1
alert response.error.message and write here. - Sahil Mittal
The error messsage is "An active access token must be used to query information about the current user." - user1386463

1 Answers

0
votes

The error is quite straight-forward. No user is currently logged-in to your application. You must call, FB.login first before making any API calls further.

After the login, the user will be in session and you wont see this error again.