我使用javascript sdk并且我已经发送审核我的publish_action,它们已被批准。无论如何,我无法发布我的帖子,我需要的范围是:
FB.login(function(response)
{
...
}, {scope: 'email,publish_actions'});
当我尝试发布返回错误时:
(#200) The user hasn't authorized the application to perform this action
这是真的,因为在facebook模式登录中,只显示了阅读个人资料信息的权限,没有发布权限。我怎么解决?
编辑
我添加完整的代码以便更好地解释:
<script type="text/javascript">
/***FACEBOOK***/
function fb_publish_Photo(immaginelink,idfoto){
var testo_share= $("#share_text").text();
var wallPost = {
message: testo_share,
link:immaginelink,
picture:immaginelink
};
console.log(wallPost);
FB.api('/me/feed', 'post', wallPost , function(response) {
if (!response || response.error) {
console.log(response.error);
alert('Failure! ' + response.error + ' You may logout once and try again');
} else {
// alert('Success! Post ID: ' + response.id);
var PostId=response.id;
if(response.id!=null && response.id!=''){
FB.getLoginStatus(function (response) {
if (response.authResponse) {
} else {
// do something...maybe show a login prompt
}
}, {scope: 'publish_actions'});
}
}
console.log(response);
}, { scope: 'publish_actions'});
}
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
//fb_login();
} else if (response.status === 'not_authorized') {
} else {
}
}
function fb_login(){
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
//console.log(response); // dump complete info
access_token = response.authResponse.accessToken; //get access token
user_id = response.authResponse.userID; //get FB UID
FB.api('/me?fields=email,first_name,last_name,name', function(response) {
//chiamata ajax per registrare/loggare l'utente
console.log(response);
});
} else {
//user hit cancel button
console.log('User cancelled login or did not fully authorize.');
}
}, {
scope: 'publish_actions'
});
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxx',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.4' // use version 2.4
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
/***end FB***/
</script>
修改
这是我在facebook文档中找到的唯一参考:
function myFacebookLogin() {
FB.login(function(){}, {scope: 'publish_actions'});
}
或
FB.login(function(){
// Note: The call will only work if you accept the permission request
FB.api('/me/feed', 'post', {message: 'Hello, world!'});
}, {scope: 'publish_actions'});
看起来很简单,在登录电话中我必须要求权限,那么为什么发布权限对话框不会出现在已批准的应用中呢?
修改
这是我的应用权限的屏幕
答案 0 :(得分:0)
Publish_actions范围现在似乎正常。我有两次范围请求。