我尝试使用 FB Javascript SDK 进行 facebook 登录。
登录后不会仅在Opera浏览器中关闭登录窗口。我该如何解决这个问题?
我试过以下源代码:(在这个网站上在线 - 链接)
<html>
<head></head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '101103500012652', // App ID
channelUrl: '//www.milujse.cz/app/channel.html', // Channel File
status: true,
cookie: true,
xfbml: true
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
} else {
}
});
};
(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() {
FB.api('/me', function(response) {
alert('Good to see you, ' + response.name + '.');
});
}
function loginFB()
{
FB.login(function(response) {
if (response.authResponse) {
testAPI();
} else {
}
});
}
function logoutFB()
{
FB.logout(function(response) {
});
}
</script>
<input type="button" value="Login" onclick="loginFB();
return false;" />
<input type="button" value="Logout" onclick="logoutFB();
return false;" />
</body>
</html>