Facebook今天改变了javascript sdk身份验证吗?

时间:2012-04-18 19:00:05

标签: javascript facebook facebook-javascript-sdk

Facebook今天在javascript sdk认证方面有所改变吗?我使用了FB Javascript SDK Authetication written by Mahmud Ahsan,在今天之前一切都很好。现在它有FB.logout()的问题。尝试登录 his demo ,然后单击“注销”按钮。并尝试再次按此按钮登录。它不会回应。 Firebug说: FB.logout()在没有访问令牌的情况下调用。也许有人知道如何向FB.logout方法添加访问令牌或者..有关于此更改的文档的链接?

我的认证:

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'});   
    }
}
}

1 个答案:

答案 0 :(得分:0)

解决了!问题出在FB.event.subscribe上。我刚刚将 auth.statusChange 更改为另一个听众 - auth.authResponseChange