0

This my code:

   <div id="fb-root"></div>
   <body>
   <script>
            window.fbAsyncInit = function() {
                FB.init(
                {
                    appId: 'XXX',
                    status: true,
                    cookie: true,
                    xfbml: true,
        channelUrl: 'fbsite.url'

                });
            };

            (function() {
                var e = document.createElement('script');
                e.src = document.location.protocol + '//connect.facebook.net/en_US  /all.js';
                e.async = true;
                document.getElementById('fb-root').appendChild(e);
            }());
        //LOGIN FUNCTION 
   function login() {
    FB.login(function(response) {
        if (response.authResponse) {
            alert('Success!');
        }else{
            alert('Login Failed!');
        }
    }, {scope: 'email'});
 }

  </script>
  <div onclick="login();">Login with Facebook</div>

If I click Login with Facebook on div, that I get error, is this :

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.

Why is that?

1 Answer 1

1

Issue may be with the callback url. Check your website url and call back url which you have provided while creating your facebook application. Both of them should be same or subdomain (base domain should be same). If you are calling fb login from localhost, provide the callback url also as localhost/....

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.