在我的应用程序中,我可以登录Facebook,但我无法注销。当我单击调用注销功能的按钮时,我得到:
Object { authResponse: null, status: "unknown" }
这是我的代码:
function login_to_fb() {
FB.login(function(response) {
if (response.status === 'connected') {
window.location.reload();
}
}, {
scope: 'email'
});
}
function logout_from_fb() {
FB.getLoginStatus(function(response) {
console.log(response);
if (response && response.status === 'connected') {
FB.logout(function(response) {
window.location.reload();
});
}
});
}
我想通了,这是因为我刷新了页面。没有它,脚本可以正常工作,但是当我登录并刷新页面时,注销是不可能的。如何保存?
结果可能被缓存。尝试传递 true 作为第二个参数以清除缓存:
FB.getLoginStatus(function(response) {
// this will be called when the roundtrip to Facebook has completed
}, true);