1
當我從任何Facebook社交插件(如評論框或類似按鈕)登錄或註銷時,是否有任何方法捕獲Facebook事件?我想在用戶登錄到Facebook插件時刷新我的頁面。因爲當我用評論框登錄時,它不顯示我已登錄,所以我不能使用「贊」按鈕。但是當我刷新我的頁面時,它顯示我已登錄到兩個插件。當我從Facebook註釋框登錄/註銷時,如何捕獲事件?
這裏是我的代碼:
<div id="fb-root">
</div>
<script>
window.fbAsyncInit = function() {
FB.init({ appId: 'My App ID', status: true, cookie: true, xfbml: false });
setTimeout(aaa, 6000);
FB.Event.subscribe("xfbml.render", function (targetUrl) {
$("#myh1").html("Facebook Loaded");
alert('edge.create');
});
FB.Event.subscribe('auth.authResponseChange', function (response) {
alert('The status of the session is: ' + response.status);
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
function aaa() {
FB.XFBML.parse(document.getElementById('fbDiv'), function() {
alert('I rendered');
});
}
</script>
<div id="fbDiv">
<div class="fb-comments" data-href="http://www.facebook.com/AiLiveCaptions" data-num-posts="2" data-width="470">
</div>
</div>