ユーザーがページの読み込み時にログインしているかどうかを Web サイトに確認させようとしましたが、API の指示に従っても機能しませんでした。例を次に示します。
<!DOCTYPE html>
<html>
<head>
<title>My Facebook Login Page</title>
</head>
<body>
<div id="fb-root"></div>
<script>
alert('hello');
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true,
cookie : true,
xfbml : true,
oauth : true
});
FB.getLoginStatus(function( response ) {
console.log(response);
alert('hello2');
});
FB.Event.subscribe('auth.statusChange', function(response) {
alert('hello2');
});
FB.Event.unsubscribe('auth.statusChange');
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
</body>
</html>
ユーザーがログインしていない限り、アラートがヒットすることさえありません。ログアウトしている場合、このアラートまたはそのコードブロック内にあるものはトリガーされません。