私は私のhtmlのヘッドセクションに置いたこのスクリプトを持っています:
<script>
function goLogIn(){
alert("go login");
window.location.href = "{{ path('_security_check') }}";
}
function onFbInit() {
if (typeof(FB) != 'undefined' && FB != null ) {
alert('here')
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.session || response.authResponse) {
alert("login");
setTimeout(goLogIn, 500);
} else {
alert('logout');
window.location.href = "{{ path('_security_logout') }}";
}
});
}
}
</script>
したがって、ここのアラートボックスは印刷されます。しかし、ログインとログアウトを試みましたが、ログインまたはログアウトがトリガーされません。なぜですか?
Facebookボタンを初期化した方法は次のとおりです。
<!-- inside a twig template -->
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();'}) }}
{{ facebook_login_button({'autologoutlink': true, 'label': 'Log in using Facebook'}) }}