我需要一个用户可以登录的应用程序&登录后会显示一些信息。但我多次面临很多问题。请帮我纠正一下。 SOmetime显示FB无法识别,有时会显示GET文件://connect.facebook.net/en_US/all.js net :: ERR_FILE_NOT_FOUND。
<html>
<head>
<title> Facebook </title>
<script src="jquery.js"></script>
</head>
<body>
<a href = "#" onClick = "FB.getLoginStatus()">Login</a>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxx', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional init code here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
} else if (response.status === 'not_authorized') {
// not_authorized
login();
} else {
// not_logged_in
login();
}
});
};
function login() {
FB.login(function(response) {
if (response.authResponse) {
testAPI() ;
} else {
// cancelled
}
});
}
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
// Load the SDK Asynchronously
(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>
</body>
</html>
答案 0 :(得分:0)
在//前加上http:我认为这是必要的。