1

我的 Facebook 身份验证突然停止工作。FB有什么改变吗?我目前正在使用 FB Javascript SDK 从本地主机运行该站点。以下 FB 代码均无效?

alert("got here");
window.fbAsyncInit = function () {

alert("didn't get here");

FB.init({
    appId: '102671026556892', // App ID
    //appId: '384834001576531', // App ID
    channelUrl: '//localhost/channel.html', // Channel File
    status: true, // check login status
    cookie: true, // enable cookies to allow the server to access the session
    xfbml: true  // parse XFBML
});

FB.Event.subscribe('auth.authResponseChange', function (response) {
    if (response.status === 'connected') {
        // the user is logged in and has authenticated your
        // app, and response.authResponse supplies
        // the user's ID, a valid access token, a signed
        // request, and the time the access token 
        // and signed request each expire
        var uid = response.authResponse.userID;
        var accessToken = response.authResponse.accessToken;

        FB.api('/' + uid, function (user) {
            if (user) {
                loginUser(uid, user.email, user.name);
                window.location = "/users/index.html";
            }
        });

        // check an load DB            

        // TODO: Handle the access token

    } else if (response.status === 'not_authorized') {
            // the user is logged in to Facebook, 
            // but has not authenticated your app
    } else {
        // the user isn't logged in to Facebook.
    }
});
};

alert("got here too");

// Load the SDK Asynchronously
(function (d) {
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) { return; }
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
}(document));

alert("got here as well");

不在 window.fbAsyncInit 中的警报显示正常。window.fbAsyncInit 中的那个没有。它不呈现登录按钮(下面的代码)

<!-- START of Facebook LOGIN BUTTON -->            
     <div id="fb-root"></div>    
     <div class="fb-login-button" data-show-faces="false" data-width="400" data-max-rows="1"  data-size="medium" data-colorscheme="light" scope="user_about_me, email, read_stream, publish_actions">Login with Facebook</div>
<!-- END of Facebook LOGIN BUTTON -->

非常感谢任何帮助。这一切都在上周末工作。:(

4

0 回答 0