这是我的代码:
<!DOCTYPE html>
<html xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>New JavaScript SDK & OAuth 2.0 based FBConnect Tutorial |
Thinkdiff.net</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '154062364721089', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth: true
});
// Additional initialization code here
alert('Api loaded');
FB.login(function(response)
{
console.log(response);
});
};
// 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>
test
</body>
</html>
但是当我在浏览器中打开这个文件时,Facebook api 不会加载。我只看到屏幕上印有“测试”。我相信浏览器应该联系 facebook 以加载 api - 我认为这将被称为浏览器底部的连接消息,这不会发生。