我必须使用v1 graph api和sdk方法更新我们的应用程序到v2.X。
我已下载找到here
的最新facebookConnect插件我需要让用户登录才能允许我们的应用发布到用户时间线。在我必须请求publish_scope权限之前,这已经变为publish_actions。
我已经尝试过这段代码了,但显然你不能马上请求publish_actions,所以你必须先拆除它,然后先请求public_profile,然后再发布publish_actions。我在尝试同时执行public_profile和publish_actions时收到此消息
无法将publis或manage permission(publish_actions)传递给 请求授权
所以我的代码看起来像这样,但我不认为我做得对吗?我需要第二次登录吗?我应该使用其他方法吗?此外,如果用户说'#34;现在不是"对于publish_actions权限,似乎没有办法处理它,因为调用了success方法?
这是一些代码
$(this).find('#imgFacebook').on("tap", function (e) {
e.preventDefault();
var onError = function(msg, e) {
console.log(msg + JSON.stringify(e));
logout();
};
var requestPublishPermissions = function(f) {
console.log('requesting publish permission...');
facebookConnectPlugin.login(['publish_actions'], function(e) {
console.log('Permission granted: ' + JSON.stringify(e));
if (e.authResponse) {
// user has logged in and allowed permissions!! YAY
} else {
alert('There was an error logging you in to facebook, or you did not authorize the app to post on your wall');
}
}, function(e) {
onError('Permission denied: ', e);
});
};
var login = function() {
console.log('logging in...');
facebookConnectPlugin.login(['public_profile'], function(e) {
console.log('logged in successfully: ' + JSON.stringify(e));
requestPublishPermissions(e);
}, function(e) {
if (e.errorMessage != 'User cancelled dialog') {
alert('There was an error logging you in to facebook: ' + JSON.stringify(e));
}
onError('login error: ', e);
});
};
var logout = function(success) {
// check that knowone is logged in
facebookConnectPlugin.getLoginStatus(function(e) {
console.log('status is: ' + JSON.stringify(e));
if (e.authResponse && e.status == 'connected') {
console.log('logging out...');
facebookConnectPlugin.logout(function() {
console.log('logout successful...');
if (success) success();
}, function(e) {
console.log('error logging out: ' + JSON.stringify(e));
if (success) success();
});
} else {
// know one logged in
if (success) success();
}
}, function(e) {
if (success) success();
})
};
logout(login);
});
因为我不想在应用程序上保存用户详细信息,所以我确保首先调用logout,然后记录用户。
有人有任何指示吗?