Facebook API javascript FB logout Refused to display https www facebook com home php in a frame because it set X-Frame-Options to deny

0 votes

I'm working on an AngularJS site and I load the API in the HTML and integrate the Facebook API into a Controller, but I'm having trouble logging out with the Facebook SDK Javascript v2.9.

I receive the following problem when I call FB.logout() in the onclick action

Refused to display '' in a frame because it set 'X-Frame-Options' to 'deny'

HTML CODE

   <div class="top-content">      
    <!--content-->
    <fb:login-button class="btn-login" scope="public_profile,email" 
      onlogin="doFbLogin();" data-button-type="continue_with" data-
      auto-logout-link="false" data-use-continue-as="true" data-
      size="large">
    </fb:login-button>
    <button onclick="FB.logout()" class="btn">Logout</button>    
   </div>

    <script>  
        window.fbAsyncInit = function() {
            FB.init({
                appId            : 'API-KEY',
                autoLogAppEvents : true,
                status           : true,
                xfbml            : true,
                version          : 'v2.9'
          });
          FB.AppEvents.logPageView();
      };


      (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/es_ES/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));   

    </script>

AngularJS Controller Code

appController.controller('LoginCtrl', ['$scope','$window','$location','$http','sendLoginParams','checkCreds', 'setCreds','setUserSession',
    function LoginCtrl($scope, $window,$location,$http, sendLoginParams, checkCreds, setCreds, setUserSession){   
        $scope.loggin = true;        
        $window.doFbLogin = function (){                          
            var fb_token;

            function checkLoginState() {
                $window.FB.getLoginStatus(function(response) {
                    fb_token = response.authResponse.accessToken;
                    statusChangeCallback(response);
                });
            };
            function statusChangeCallback(response) {
                console.log('statusChangeCallback');
                console.log(response);

                if (response.status === 'connected') {                      
                  facebookLogin();
                }
            }



            facebookLogin = function () {                
                $window.FB.api('/me',{ fields: 'id, name, email' }, function(response) {
                    console.log(response);
                    console.log('Successful login for: ' + response.name);
                    console.log('Successful login for: ' + response.email);
                    var id = parseInt(response.id);  
                    var postData = {
                        "user_fb_id":id,                
                        "user_fb_token": fb_token,
                        "user_email":response.email,
                        "user_avatar":"http://graph.facebook.com/" + response.id + "/picture?type=normal",

Can someone please help me with this?

Aug 4, 2022 in PHP by Kithuzzz
• 38,000 points
1,824 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
0 answers

PHP using extract() to pass array values as variables and display it on a page

In order to include a specific file ...READ MORE

Aug 6, 2022 in PHP by Kithuzzz
• 38,000 points
1,342 views
0 votes
1 answer

How to implement a callback in PHP?

Hello, Implementation of a callback is done like ...READ MORE

answered Apr 15, 2020 in PHP by Niroj
• 82,840 points
1,038 views
0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,840 points
5,362 views
0 votes
1 answer

How do I convert a PDF document to a preview image in PHP?

Hello @kartik, You need ImageMagick and GhostScript <?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,840 points
4,824 views
0 votes
1 answer

How to resolve the problem of losing a session after a redirect in PHP?

Hello @kartik, Carry out these usual checks: Make sure session_start(); is ...READ MORE

answered Aug 24, 2020 in PHP by Niroj
• 82,840 points
35,174 views
0 votes
1 answer

How to properly URL encode a string in PHP?

Hello @kartik, For the URI query use urlencode/urldecode; for ...READ MORE

answered Oct 19, 2020 in PHP by Niroj
• 82,840 points
3,159 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 1,191 views
+1 vote
1 answer

What is css box module?

Hey, All the element present in html follows ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 1,224 views
0 votes
3 answers

Explain the difference between visibility:hidden; and display:none?

display:none means that the tag in question will ...READ MORE

answered Dec 14, 2020 in Web Development by Gitika
• 65,770 points
119,791 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 3,034 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP