-1

FB.login 失败并在 FB.login 上停止执行。我只能看到几秒钟的 Facebook 登录弹出窗口,上面写着“正在加载”,然后它消失了,什么也没有发生。

我有身体标签

<div id="fb-root"></div>
    <script>
        window.fbAsyncInit = function() {
            // init the FB JS SDK
            FB.init({
            appId      : '129519787234412', // App ID from the App Dashboard
            channelUrl : '<?=URL?>facebookChannel.php', // Channel File for x-domain communication
            status     : true, // check the login status upon init?

            xfbml      : true  // parse XFBML tags on this page?
            });

            // Additional initialization code such as adding Event Listeners goes here

        };

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


    </script>

毕竟是 HTML,在脚本标签中:

$(".box_top_img").click(function(){ 

    FB.login(function(response) {

        if (response.authResponse) {
            FB.getAuthResponse()['accessToken'];
            FB.api('/me', function(response) {

                $.ajax({
                    url:"ajax/check_vote.php",
                    type:"POST",
                    data:response,
                    success:function(response){
                        var result = $.parseJSON(response);

                        if(result.code == 0){
                            $("#container_1").hide();
                            $("#container_2").hide();
                            $("#container_3").show();

                        }else if(result.code == 1){
                            $("#container_1").hide();
                            $("#container_2").show();
                            $("#container_3").hide();

                            $("#facebook_id").val(result.id);

                            if(result.first_name)
                                $("#name").val(result.first_name);
                            if(result.last_name)
                                $("#lastname").val(result.last_name);
                            if(result.email)
                                $("#email").val(result.email);

                        }else{
                            $("#container_1").show();
                            $("#container_2").hide();
                            $("#container_3").hide();

                        }
                    }
                });
            });
        } else {
            console.log('User cancelled login or did not fully authorize.');
        }
    }, {scope: 'email'});
});

谢谢!!

4

2 回答 2

1

检查应用设置页面上的沙盒模式是否被禁用

于 2013-04-16T20:11:56.427 回答
0

您可以尝试替换facebook-jssdkfb-root. 这应该有效。

于 2013-04-11T09:20:27.347 回答