0

The last 4 days I try to start my first Facebook application but everything that I try fails and I would like to have some help from someone who has developed Facebook application. Initially I tried the script that Facebook gives when a user creates a new Facebook application. The script is the following which I added after the opening .

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '1406185529679324',
      xfbml      : true,
      version    : 'v2.2'
    });

    // ADD ADDITIONAL FACEBOOK CODE HERE
  };

  (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'));
</script>

The problem is that the window.fbAsyncInit function was never executed. I added an alert inside this function and I never saw the message. In the browser I had the following error message:

GET https://connect.facebook.net/en_US/sdk.js net::ERR_INSECURE_RESPONSE

Does anyone knows what is wrong with my application? Should I change something in the Facebook application settings?

Kind regards Aristotelis

pitaridis
  • 2,801
  • 3
  • 22
  • 41

2 Answers2

1

You are most likely trying it without a server. Don´t change the implementation code, you only need to run it on a real server. You can also use localhost, but make sure to start a server on your computer and don´t just open the html file in a browser. If it still does not work on a real server, post a test link.

Adding http/https is a very bad idea, it will work on a real server and it will take the protocol from the real server - don´t mix protocols. And don´t just use any fix someone posted, make sure you understand what´s happening ;)

andyrandy
  • 72,880
  • 8
  • 113
  • 130
0

i think that your answer is here “Failed to load resource” using Facebook's example code

you have to change js.src assignment to: js.src="https://connect.facebook.net/en_US/all.js" and also you have to host your html file in a webserver

Community
  • 1
  • 1
badr slaoui
  • 1,023
  • 11
  • 27
  • Thanks for the replies. I have to say that I tried to add the https in front of the url and I also host the file in an https server. I have tried everything but nothing worked. I have spent a lot of time trying to find a solution but I did not find something useful. – pitaridis Jan 25 '15 at 18:37
  • I am getting the exact same error and I have tried everything you said. No success. Let me know if you have figured this out – JSNoob Aug 06 '16 at 02:55