简体   繁体   中英

Facebook authentication won't work

My website is using Facebook Connect, but since a month it's not working. I suspect that Facebook changed something. I tried to find out, but it was impossible. I have a Java file that initiates the authentication, but I don't know if that file is the problem. Well, basically it connect, but it's not returning the registration form of my website.

   window.fbAsyncInit = function() {
FB.init({appId: cfg_facebook_app_id, status: true, cookie: true, xfbml: true}); 


    //initial login check
FB.getLoginStatus(function(response) {
    if (response.session) {
        //logged in, force logout
        FB.logout(function() {
          //logged out, subscribe to events
          loginEvents();
        });
    } else {
        //not logged in
        loginEvents();
    }
});

function loginEvents() {
    FB.Event.subscribe('auth.logout', function(response) {
        // do something with response
        logout();
    });

    FB.Event.subscribe('auth.login', function(response) {
        login(response);
        //login redirects the user. Before logout fires()
        });
        }

     };
    (function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
    }());

    function login(){
FB.api('/me', function(response) {
    window.location = cfg_site_url + 'facebook_auth.php?hashcode='+response.id;
});
    }

try{} updating to the new version of javascript sdk https://developers.facebook.com/docs/reference/javascript/

As of December 13th, 2011, the JavaScript SDK now only supports OAuth 2.0 for authentication. The ability to enable OAuth 2.0 in the JS SDK was first introduced in July. All apps were given until October 1, 2011 to test and migrate. With this change, please ensure that you are using FB.getAuthResponse to obtain the access token.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM