我正在嘗試將Facebook登錄與我的網站進行整合,並且我現在正在通過本地主機測試我的Facebook登錄。這是我根據Facebook JavaScript SDK指南中的說明生成的代碼。Facebook JS SDK無法加載資源
<html>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '*************', // App ID
channelUrl : 'http://localhost', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
testAPI();
} else if (response.status === 'not_authorized') {
// not_authorized
login();
} else {
// not_logged_in
login();
}
});
};
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
testApi();
} else {
// cancelled
console.log('Login failed!');
}
});
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
}
(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));
</script>
<script src="//connect.facebook.net/en_US/all.js"></script>
</body>
</html>
它說,它無法加載資源:file://connect.facebook.net/en_US/all.js
它基本上是失敗的GET all.js.怎麼了?
我的Facebook應用程序儀表板有localhost
作爲AppDomain和網站URL爲http://localhost
。
我是否應該用我的代碼替換部分代碼?或者我只是將它插入某處? – dtgee 2013-02-22 07:42:29
[Blog](http://webuntudro.com/connect-with-facebook/) – Sadik 2013-02-22 07:52:45