skip to Main Content

Situation: User load page and check if the user is Logged in facebook.

Problem: After the function .getLoginStatus (see js) I get the
ERROR message: Refused to display …https://www.facebook.com/connect/ping? … ‘X-Frame-Options’ to ‘deny’

I have an other website which I didnt changed the FB-Code but there is not working anymore.

Data: v2.10

Checked: Firefox (fails), Chrome (fails), Edge (success)

I hope someone can help me.

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'));
    }
}

2

Answers


  1. Chosen as BEST ANSWER

    I found this enter link description here

    Its still the problem if I will check is the user Logged in but its possible to Log in if the user click self the fb button =)


  2. Just got this same error, and what eventually worked for me was changing the site url in the app dashboard settings to my development URL. This is the answer that pointed me in the right direction after spending quite some time blocked — https://stackoverflow.com/a/53325827/3787212

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search