简体   繁体   中英

About the facebook javascript sdk

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM