简体   繁体   中英

Post on Facebook Wall via Javascript

I tried to post on facebook wall using below code-

function facebook_login() {
    FB.login(function (response) {
        if (response.authResponse) {
            FB.api('/me/feed', 'post', { message: 'Hello, world!' }, function(status) {
                if (!status || status.error) {
                  console.log('Error occured');
                } else {
                  console.log('Post ID: ' + status.id);
                }
            });
            FB.api('/me', function(response) {
                var user_profile = JSON.stringify(response);
            });
        }
    },{scope: 'email,publish_actions,user_birthday,offline_access'});
}

But It throw me this error:

code: 200

message: "(#200) The user hasn't authorized the application to perform this action"

type: "OAuthException"

I do not understand what I did wrong.

offline_access is deprecated since years, and you don´t need it anyway. You only need publish_actions for posting, and you need to go through a review process before it works for any user. Make sure the publish_actions permission gets asked for in the authorization popup, and only try with an app admin/developer.

That error message means that you did not authorize correctly with publish_actions .

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