Twitist Forums
Failed to Load Resource Javascript? - Printable Version

+- Twitist Forums (http://twitist.com)
+-- Forum: Facebook forums (/forum-14.html)
+--- Forum: Facebook Pages (/forum-13.html)
+--- Thread: Failed to Load Resource Javascript? (/thread-105374.html)



Failed to Load Resource Javascript? - Edward - 02-26-2014 03:19 AM

<html>
<head></head>

<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function()
{
FB.init
({
appId : '239358039572033',
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)
{
if (response.status === 'connected')
{
testAPI();
}
else if (response.status === 'not_authorized')
{
FB.login();
}
else
{
FB.login();
}
});
};
(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>

This html code is literally copied directly off the facebook app developer page for the login screen, with my app's id placed where it's supposed to be. Every time I click the .html file though, I get an error saying "failed to load resource" referring to file://connect.facebook.net/en_US/all.js

Since I didn't change anything except what they told me to do I'm guessing I'm doing something wrong with how I'm loading the app so I was wondering if somebody could help me out here

I created the app in developers.facebook.com, and copied the Application ID to the file. Might be something having to do with the hosting on Parse.com - if anyone could point me to an easy tutorial for hosting html files on parse.com I'd be grateful
Ok that worked, but now when I click login I get another error saying "Given URL is not permitted by the application configuration.: One or more of the given URLs is not allowed by the App's setting. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains"


- Chris - 02-26-2014 03:26 AM

The problem is that you're opening this file on your own computer, not on a server.
The script is linked using the "//.." notation, which will use the same protocol as the page, in this case "file", not "http".

Try changing this line:
js.src = "//connect.facebook.net/en_US/all.js";

to:
js.src = "http://connect.facebook.net/en_US/all.js";

(yahoo cuts off the line, just add "http:" at the start)