1

我的代码在过去 24 小时之前都运行良好。我没有改变任何东西,但现在#fb 按钮变小了,它不再显示“注销”。

您可以在Homewrd看到这一点。

以下代码嵌套在 BODY > ROOT 中:

<div id="fb-root"></div>
<script type="text/javascript">
    // 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));

    // Init the SDK upon load
    window.fbAsyncInit = function() {
        FB.init({
            appId:'271193286279763',
            channelUrl:'//'+window.location.hostname+'/channel',
            status:true,
            cookie:true,
            xfbml:true
        });

        // Conditional UI for landing page
        if (landing) {
            FB.getLoginStatus(function(response) {                                                                                                                              
                if(response && response.status == 'connected') {                                                                                                                
                    FB.api('/me', function(response) {
                        var heading = $('#goods h1').text().replace('Homewrd','Welcome '+response.first_name+'!');
                        $('#goods h1').text(heading);
                    });
                }
            });
        }

        // listen for and handle auth.statusChange events
        FB.Event.subscribe('auth.statusChange', function(response) {
            fbEventful = true;
            if (response.authResponse) {
                fbToken = response.authResponse.accessToken;
                $('#fb-button').css({'display':'inline','float':'left'});
                $('#toolbox').css({'display':'inline'});
                $('#local-login').hide();
                $('#local-logout').hide();
                currentUser = {
                    fbid:response.authResponse.userID
                }
                displayPicture();
            } else {
                $.cookie('cuat', null);
                $.ajax({
                    url:'/logout.json',
                    type:'delete',
                    success:function() {
                        ajaxOff();
                        renderLocal();
                    }
                });
            }
        });

        FB.Event.subscribe('auth.login',
            function(response) {
                FB.api('/me', function(me){
                  if (me.name) {
                    currentUser = {
                        fbid:me.id,
                        email:me.email,
                        first_name:me.first_name,
                        last_name:me.last_name
                    }
                    params = {
                        fbid: currentUser.fbid,
                        user: {
                            fbid:currentUser.fbid,
                            email:currentUser.email,
                            first_name:currentUser.first_name,
                            last_name:currentUser.last_name
                        }
                    }
                    $.ajax({
                        url:domain+'/user.json',
                        data:params,
                        dataType:'json',
                        type:'post',
                        success:function(e) {
                            cuat = e.user.auth_token;
                            $.cookie('cuat', cuat, {
                                path:'/',
                                expires:7
                                }
                            );
                            if (rurl) {
                                refreshSession();
                            }
                            if (storedProcedure!==null) {
                                storedProcedure();
                            }
                        }
                    });
                  }
                });
            }
        );

        $('#local-logout a').click(function(e) {
            e.preventDefault();
            var x = confirm('Are you sure that you want to logout?');
            if (x===true) {
                ajaxOn();
                $.ajax({
                    url:'/logout.json',
                    type:'delete',
                    success:function() {
                        ajaxOff();
                        window.location.reload();
                    }
                });
            }
            return false;
        });

        setTimeout(function() {
            if (!fbEventful) {
                renderLocal();
            }
        },1000);
    }
</script>
<div id="header">
    <div id="logo">
        <h1>Logo Link</h1>
    </div>
    <div id="session">
        <div id="fb-button" autologoutlink="true" class="fb-login-button" scope="publish_stream,email,user_about_me,user_birthday,user_hometown,offline_access"></div>
        <div id="fb-picture"></div>
        <div id="local-login"><p>local login link</p></div>
        <div id="local-logout"><p>local logout link</p></div>
    </div>
</div>
4

0 回答 0