Reputation: 1750
I am trying to build a Facebook app using Js file provided by them.
I am able to get User Registered for my App, But I have to post Feeds on their wall (also I don't want the Pre-Confirmation message for the User's Approval, User should only Login into his/her account).
Following is the Code:
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
FB.init({ appId: '<%: Facebook.FacebookApplication.Current.AppId %>', status: true, cookie: true, xfbml: true });
var userName;
FB.login(function (response) {
//alert('1');
if (response.authResponse) {
var access_token = FB.getAuthResponse()['accessToken'];
//alert('Access Token = ' + access_token);
FB.api('/me', function (response) {
alert('Good to see you, ' + response.name + '.');
userName = response.name;
document.getElementById('btnPostFeed').style.display = 'block';
});
} else {
document.getElementById('btnPostFeed').style.display = 'none';
//console.log('User cancelled login or did not fully authorize.');
}
}, { scope: '' });
function SubmitPost(msg) {
try {
if (userName != null || typeof userName != 'undefined') {
var wallPost = {
message: msg + " By : " + userName,
picture: '',
link: '',
name: 'test app posted in your wall',
caption: '',
description: ('Test description')
};
FB.api('/me/feed', 'post', wallPost, function (response) {
if (!response || response.error) {
/*action*/
alert('Message could not be Posted.');
alert(response.error.message);
} else {
/*action*/
alert('Message Posted successfully.');
}
});
}
else {
alert('Please wait while User Info is Loaded..');
}
}
catch (err) { alert('SubmitPost: ' + err); }
My Main issue is: I get (#200) The user hasn't authorized the application to perform this action
Following is the Screen shot for the App Registration:
What should I do for this?
Upvotes: 2
Views: 6364
Reputation: 19995
Your scope is completely empty in this line
}, { scope: '' });
If your don't request the correct permission you will not be authorized for it.
But I have to post Feeds on their wall (also I don't want the Pre-Confirmation message for the User's Approval, User should only Login into his/her account).
This makes no sense, your user needs to approve you to post to their wall. If they only login they only grant you the most basic permissions exclusive of posting to their wall.
Upvotes: 1