我的认证:
window.fbAsyncInit = function() {
FB.init({ appId: '*************',
status: true,
cookie: true,
channelUrl: '//localhost/website/channel.html', // Channel File
xfbml: true,
oauth: true});
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
};
var button,userInfo;
function updateButton(response) {
button = document.getElementById('fb-auth');
userInfo = document.getElementById('userInfo');
if (response.authResponse){
FB.api('/me', function(info) {
login(response, info); //function will just change text on the button..
});
button.onclick = function() {
FB.logout(function(response) { //here we are, FB.logout method =\
logout(response); //function will just change text on the button..
});
};
} else {
button.innerHTML = 'Login';
button.onclick = function() {
showLoader(true);
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(info) {
login(response, info);
});
} else {
//user cancelled login or did not grant authorization
alert('you are not logged in to facebook or have not granted this app basic permissins. please log in and grand basic permissins to user this application');
}
}, {scope:'email,user_birthday,user_about_me'});
}
}
}
答案 0 :(得分:0)
解决了!问题出在FB.event.subscribe上。我刚刚将 auth.statusChange 更改为另一个听众 - auth.authResponseChange