window.fbAsyncInit = function() {
FB.init({
appId: 'myAppId',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('comment.create',
function (response) {
console.log('create', response);
});
FB.Event.subscribe('comment.remove',
function (response) {
console.log('remove', response);
});
};
(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);
}());
<fb:comments class="fb-comments" href="myFirstCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
<fb:comments class="fb-comments" href="mySecondCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
<fb:comments class="fb-comments" href="myThirdCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
<fb:comments class="fb-comments" href="myFourthCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
<script>
//INCLUDE THE SCRIPT FIRST
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={YOURAPPID}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
//INITIALIZE THE OBJECTS
window.fbAsyncInit = function() {
FB.init({
appId: '{YOURAPPID}',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
//AND THOSE WILL FIRE THE EVENTS :)
FB.Event.subscribe('comment.create',
function (response) {
console.log('create', response);
});
FB.Event.subscribe('comment.remove',
function (response) {
console.log('remove', response);
});
};