after all stack overflow solution still cant fb login on my local host server

65 views Asked by At

The most voted answer to change host file I have change into my website name which is not live domain but on my local domain

127.0.0.1       localhost
127.0.0.1       localhost/great

after this I made test application also fbdevelopers and change domain into localhost

enter image description here

and after this I have comment all the fb login code of running app on live server and integrate fb login code

function statusChangeCallback(response) {
    alert("yes");
    console.log('statusChangeCallback');
    console.log(response);


    if (response.status === 'connected') {
      // Logged into your app and Facebook.
      testAPI();
    } else {

      document.getElementById('status').innerHTML = 'Please log ' +
        'into this app.';
    }
  }


  function checkLoginState() {
    alert("here");
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });
  }
  window.fbAsyncInit = function() {
    alert("ghhh");
    FB.init({
      appId      : '1726174127690844',
      xfbml      : true,
      version    : 'v2.10'
    });
    FB.AppEvents.logPageView();
  };


  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });

  };


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


  function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Successful login for: ' + response.name);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + response.name + '!';
    });
  }

and the button of fb login

<fb:login-button 
  scope="public_profile,email"
  onlogin="checkLoginState();">
</fb:login-button>
  <div id="status">
</div>

but still getting an error

Can't Load URL: The domain of this URL isn't included in the app's domain

please genius where I am wrong do correct me please kindly give me your expert advice

1

There are 1 answers

6
Vikram On

You should add new temporary domain or use your live site domain while you are developing it on your localhost for your localhost like

127.0.0.1       yoursitedomain.com

and use yoursitedomain.com as fb app domain this way fb will not reject the domain and you will be able to implement it from your localhost too