Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB.Event.subscribe + comments.add don't work?

Tags:

facebook

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>   
like image 248
andyr Avatar asked Jun 17 '10 08:06

andyr


1 Answers

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>
like image 176
fabianadipolo Avatar answered Sep 19 '22 12:09

fabianadipolo