I've attached patch, a first draft, at keeping track of the comment count.

When the node is accessed it queries facebook's API and updates the database with the comment count.
I've added configuration options it's make the feature optional, as well as setting a minimum wait time inbetween checking for updates.

The comment count can be accessed in views.

UPDATE: that patch was a fail... I'll have a go at re-rolling it.

Comments

wmostrey’s picture

With the color scheme patch in place, you are free to re-roll.

wmostrey’s picture

Status: Active » Needs work
jackread’s picture

StatusFileSize
new5.36 KB

here's a re-rolled patch that doesn't suck :-)

jackread’s picture

Still TO DO:

  • option of syncing comment count on cron job
  • add a comment count link to the node "links"
askibinski’s picture

Just a quick note:
I didn't use this module, but I do use facebook comments on a D6 site instead of drupal comments.

I wanted to have the core `node_comment_statistics` table being updated each time a FB comment was made. This is easily done by applying a ajax callback and some custom code.

JS:

  window.fbAsyncInit = function() {
    /* new comment */
    FB.Event.subscribe('comment.create', function (response) {
      $.ajax({
        url: '/count/comment',
        data: 'js=1&path='+window.location.pathname,
        dataType: 'json',
        type: 'POST',
        success: function(data){
            alert(data); 
        }
      });
    });
  };

And in your php add a hook_menu for count/comment which does a db_query (and of course some validation).
You can also use 'comment.remove' to create a callback which counts down when somebody removes his/her comment.

The benefits of doing it this way is that the counts are available in core statistics/views/etc.

charmi’s picture

if you want to know the total no.of comments left on your page then the fb:comments-count tag will emit the number of comments on your URL in a tag. for eg: if you want to show no.of comments in dummy.com you can include the following :

<fb:comments-count href=http://dummy.com/></fb:comments-count> Total comments

Hope this might help you!

jcmartinez’s picture

Status: Needs work » Needs review
StatusFileSize
new41.27 KB

The attached patch adds a few changes that I had to make in order to meet the needs of a project. I'm sharing it in case it could help someone else.

The changes that this patch provides are:

  • Implements an option for adding the comment count to node links as suggested on #4
  • Switches from Graph to FQL for retrieving comments count. The Graph API was not reliable on my tests.
  • To do the above, the use of Facebook PHP SDK was implemented.
  • Added a debug option for showing the raw result from querying Facebook.
  • Added README.txt file with instructions on how to install.

Note: This patch was made against version 7.x-1.x-dev from 2012-Aug-08 and it contains most of the code added on a previous patch by jackread on comment #3. Therefore; by applying this patch most changes from the other patch will be applied as well.

Please let me know if you find problems and thank you for creating this great module.

jcmartinez’s picture

Issue summary: View changes

patch fail