I'm trying to catch event when comment is sent. What am I doing wrong? I just want to update every user comment also to facebook group wall and that's why I need to catch the event.
<fb:comments numposts="10" ></fb:comments>
FB.init and event catcher:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'sensored-app-id',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
/* All the events registered */
FB.Event.subscribe('comments.add', function (response) {
// do something with response
alert("comment added");
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/fi_FI/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
You need to add notify="true"
attribute to the fb:comments
tag. Once you add the attribute the comments.add event begin to work.
<fb:comments numposts="10" notify="true"></fb:comments>
or, if you're using the newer html5 compliant tags:
<div class="fb-comments" data-num-posts="10" data-notify="true" ></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With