2
votes

I have created a small application in local host.

I have checked in the wieshark that :

Request going is :

HTTP GET: http://www.facebook.com/dialog/oauth?api_key=APPID&app_id=APPID&channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D9%23cb%3Df17ca8709c%26origin%3Dhttp%253A%252F%252F127.0.0.1%253A8080%252Ffd1147b44%26domain%3D127.0.0.1%26relation%3Dparent.parent&client_id=121312018012923&display=none&domain=127.0.0.1&locale=en_US&origin=1&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D9%23cb%3Df164e7a46c%26origin%3Dhttp%253A%252F%252F*127.0.0.1%253A8080%*252Ffd1147b44%26domain%3D127.0.0.1%26relation%3Dparent%26frame%3Df216567208&response_type=token%2Csigned_request%2Ccode&sdk=joey

Facebook is sending 200 OK:

[truncated] 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 o

I am not getting what the issue is : I have XAMPP running on my localhost. In the canvas and site URL I have : http://mytestdomain.com:8080.

in my machine in /etc/hosts I have 127.0.0.1 mytestdomain.com.

The Actual code I am running

<body>
        <div id="fb-root"></div>
<script>

      window.fbAsyncInit = function() {
          FB.init({appId: 'APPID', status: true, cookie: true, xfbml: true});

      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());

      FB.getLoginStatus(function(response) {         
        if (response.status == "connected") {
        alert("yes I am in ");
        }
        else{
        alert(" you need to login to facebook:");
        }
        });

    function checkFacebookLogin() {
    alert("hai");
    }

    </script>


 <p id="fb_login_button_1"><fb:login-button onlogin="checkFacebookLogin();" size="medium" scope="email">Sign in using Facebook</fb:login-button></p>

</body>
7

7 Answers

1
votes

The address you are debugging to in Visual studio needs to match your https://developers.facebook.com/ "Site URL" exactly. I would recommend debugging with IIS and manually create a virtual directory to match your Site URL. (Plus you don't have to specify a port, which I have found to cause issues sometimes if it isn't the default 80 or 443 port)

In my case with this issue, I had a "http://www.domain.com/App" when debugging, but my Facebook Developer Site URL was "http://domain.com/App". I have also seen people leave the slash "/" off or had "https" instead of "http".

Bottom line is that you need to make sure your URLs match spot on. Facebook appears to be extremely picky.

0
votes

at your app config in Facebook does you app URL points to your localhost?

0
votes

From what i know. Facebook dont allow anymore test your app in localhost.

0
votes

I Think you might be using same app and secret key for more than one site. You need to change the app and secret keys for your site you can generate your keys from appsfacebook developer

For me this worked hope this will help you

0
votes

Try setting up a virtual host on your local server. One you do you'll be able to create virtual URLs. If you then set the URL in your facebook app to the virtual URL, I believe you'll be able to make some facebook calls from the local server, however if I recall correctly you still won't be able to publish to the graph.

0
votes

Just another possibility: in my situation, I have multiple WP plugins / scrips calling FB code, and differing AppIDs on local and production - at one stage I was overlooking a conflict between the local / production config.

-1
votes

Take a look at the following, and try:

  1. App Domains: your-domain.com
  2. Website with Facebook Login: your-domain.com:8080
  3. In C:\Windows\System32\drivers\etc\hosts, Add the entry 127.0.0.1 your-domain.com
  4. In the browser address bar type: http://your-domain.com:8080/appname

That's it!