0

I've just tried to make a fecebook login for my website and trying to test the following in local..which is located localhost inside a project folder name 'facebooklogin'

<html>
<head></head>
<body>
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
  FB.init({
    appId      : 'xxxxxxxxxxxxxxxx',
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
  });
  FB.Event.subscribe('auth.authResponseChange', function(response) {
    console.log(response);

    if (response.status === 'connected') {
      testAPI();
    } else if (response.status === 'not_authorized') {
      FB.login();
    } else {
      FB.login();
    }
  });
  };
  // Load the SDK asynchronously
  (function(d){
   var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
   if (d.getElementById(id)) {return;}
   js = d.createElement('script'); js.id = id; js.async = true;
   js.src = "//connect.facebook.net/en_US/all.js";
   ref.parentNode.insertBefore(js, ref);
  }(document));

  function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Good to see you, ' + response.name + '.');
    });
  }
</script>

<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>
</body>
</html>

but it shows the error in console.. what is proper way of redemption from this issues in local machine...?

And what will be the App Domain if I wanna test it in local..? I tried with 'localhost' or 127.0.0.1 but it shows alert like this

It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

Codegiant
  • 2,110
  • 1
  • 22
  • 31
  • actually you cannot test facebook login at localhost you shoul test it at the domain which you give at your facebook application. and can you give your console errors – semirturgay Dec 26 '13 at 19:37
  • @SemirTurgay here is what is in the console "Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains. " – Codegiant Dec 26 '13 at 19:48
  • like i said before. You should test the facebook login api at your domain that you give when you create your facebook application at facebook developers – semirturgay Dec 26 '13 at 19:50
  • Do you mean the App Domain in app settings? – Codegiant Dec 26 '13 at 19:54
  • yes exactly. you should test your login app at that domain. you cannot test it at localhost – semirturgay Dec 26 '13 at 19:56
  • but i can't set the App Domain there it shows the alert like this "It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains." – Codegiant Dec 26 '13 at 19:57
  • your application id tells the facebook that your application runs on the domain that you give the facebook as app domain but you try to run your application with another domain like localhost. – semirturgay Dec 26 '13 at 20:05
  • look at here : http://stackoverflow.com/questions/2459728/how-to-test-facebook-connect-locally – semirturgay Dec 26 '13 at 20:10
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43946/discussion-between-codegiant-and-semir-turgay) – Codegiant Dec 26 '13 at 20:11

0 Answers0