首页 文章

Facebook API登录getLoginStatus拒绝显示 . . . 'X-Frame-Options'至'deny' v2.10

提问于
浏览
2

Situation: 用户加载页面并检查用户是否登录Facebook .

Problem: 在函数 .getLoginStatus 之后(参见js)我得到了
ERROR message: 拒绝显示...... https://www.facebook.com/connect/ping? ... 'X-Frame-Options'至'deny'

我有一个其他网站,我没有改变FB代码,但不再工作了 .

Data: v2.10

Checked: Firefox(失败),Chrome(失败),Edge(成功)

我希望有一个人可以帮助我 .

Button

<div id="fb-root">
    <div class="fb-login-button" data-max-rows="3" data-size="large" data-button-type="login_with" data-show-faces="false" data-auto-logout-link="false" data-use-continue-as="false" data-scope="public_profile,email"
        data-mislogin="<?php echo isset ( $_SESSION ['userData'] [0] ['logInStatus'] )?'true':'false';?>" data-fbappId="<?php echo $fb_appId;?>"></div>
</div>

Javascript code Class

/**
 * Facebook Login Handler
 */
var FBLoginHandler;

var isUserLog;
var isUserLoggedIn;

FBLoginHandler = new FBLoginHandler();

isUserLog = true;

FBLoginHandler.start();

function FBLoginHandler() {

    this.start = function() {

        var fb_graphVersion;
        var fb_appId;

        var fbLoginBt;

        fb_graphVersion = 'v2.10';
        fbLoginBt = $('.fb-login-button');

        if (fbLoginBt.length > 0) {

            fb_appId = fbLoginBt.attr('data-fbappId');
            isUserLoggedIn = fbLoginBt.attr('data-mislogin');

            if (isUserLoggedIn === 'false' || isUserLoggedIn === false) {

                window.fbAsyncInit = function() {
                    FB.init({
                        appId : fb_appId,
                        autoLogAppEvents : false,
                        xfbml : true,
                        version : fb_graphVersion
                    });

                    FB.AppEvents.logPageView();

                    FBLoginHandler.checkLoginState();
                }

                this.createLoginBt(fb_graphVersion,fb_appId);
            }
        };

        /*
         * This function is called when someone finishes with the Login Button. See the onlogin handler attached to it in the sample code below.
         */
        this.checkLoginState = function() {

            // Now that we've initialized the JavaScript SDK, we call
            // FB.getLoginStatus(). This function gets the state of the
            // person visiting this page and can return one of three states to
            // the callback you provide. They can be:
            //
            // 1. Logged into your app ('connected')
            // 2. Logged into Facebook, but not your app ('not_authorized')
            // 3. Not logged into Facebook and can't tell if they are logged into
            // your app or not.
            //
            // These three cases are handled in the callback function.
            FB.getLoginStatus(function(response) {
                FBLoginHandler.statusChangeCallback(response);
            });
        }

        /*
         * The response object is returned with a status field that lets the app know the current login status of the person. Full docs on the response object
         * can be found in the documentation for FB.getLoginStatus().
         */
        this.statusChangeCallback = function(response) {

            if (response.status === 'connected') {

                // Logged into your app and Facebook.
                FBLoginHandler.isFbLoginRight();
            } else if (response.status === 'not_authorized') {
                // The person is logged into Facebook, but not your app.

            } else {
                // The person is not logged into Facebook, so we're not sure if
                // they are logged into this app or not.

            }
        }

        /**
         * AJAX Meldung sobald der Benutzer sich in Facebook eingelogt hat.
         */
        this.isFbLoginRight = function() {

            $.get(domain_https_basicfull_www
                    + '/ajax/facebook/checkfblogin/?modus=x', function(result) {

                //0=Fehler bei der Anmeldung, 1=Anmeldung Erfolgreich-Seite wird neu geladen.
                var fbLoginResult = JSON.parse(result);

                switch (fbLoginResult.resultNr) {
                    case '0' :
                        swal({
                            title : LanguageBasic.getString('Error') + '!',
                            html : 'Facebook',
                            type : 'error'
                        })
                        break;
                    case '1' :
                        location.reload();
                        break;
                    default :
                        break;
                }
            });

        }
    }

    this.onLoginSubmit = function() {

        $(".fb-login-button").off("onlogin");

        $(".fb-login-button").on("onlogin", function(e) {

            FBLoginHandler.checkLoginState()

            return false;
        });
    }

    this.createLoginBt = function(fb_graphVersion,fb_appId) {

        (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/sdk.js#xfbml=1&version="+fb_graphVersion+"&appId="+fb_appId;
          fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    }
}

1 回答

  • 0

    我发现了这个enter link description here

    它仍然是问题,如果我将检查是用户登录但它可以登录如果用户单击自我fb按钮=)

相关问题