Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When posting on facebook page using javascript API, I'm having problem (#200) the user hasn't authorized the application to perform this action. I've already created an HTML page from where i'm trying to post on facebook page using javascript API. Its working fine for current admin user of the page but giving #200 Unauthorized access kind of error when login with different user. I tried to go with some stuff like Page Tab platform in app but it is demanding Secure page tab url. What is that ? Please help me out with working sample code anyone.
Email me on parixitdipak@gmail.com

What I have tried:

I tried to use FB.init() with AppId and same login and other methods of facebook javascript api. It allows me to post image or simple feed on facebook page as a admin but problem with different user. Below is the code

function login() {
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
console.log('Logged in');
}
else {
FB.login(function (response) {
if (response.authResponse) {// handle the response
console.log('Authenticated');
}
FB.api('/me', function (response) {
console.log(response.name + ' has Logged in.');
});
}, { scope: 'manage_pages, publish_actions, publish_stream' });
}
});
}


function postonwall() {
var access_token1 = FB.getAuthResponse()['accessToken'];
var msg = 'Hello World';
var page_id = 'xxxxxxxxxxxxxxx';
FB.api('/' + page_id + '/feed', 'post', { message: msg, access_token: access_token1 }, function (response) {
if (!response || response.error) {
console.log("Error in Feed posting." + response.error.message);
} else {
console.log("Feed posted successfully.");
}
});

}


Calling two function onclick of button.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900