有谁知道为什么我的网站上没有加载 Facebook 登录对话框..?
正如您将在下面看到的,我在 window.fbAsyncInit 之外的另一个函数中有 FB.getLoginStatus,并从我的登录按钮调用它。
cconsole 窗口上没有出现任何错误..!
<div id="fb-root"></div>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : '503635172990168', // App ID
channelUrl : '//http://www.angeloscleanthous.com/chat/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
});
};
function doLogin(){
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
} else if (response.status === 'not_authorized') {
login();
} else {
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>
-------------HTML PART------------(登录按钮)
<button onclick="doLogin();" class="classname">Login</button>