2

I am on Drupal 7.

I need to add a Facebook like button that will be associated with organic groups pages. Each group will have a different like button so that each group has an independent "Likes" count. I can do this by simply configuring and adding a Facebook iframe or XFBML interface. More about this here: http://developers.facebook.com/docs/reference/plugins/like/.

What I cannot figure out is how to retrieve this information from Drupal and use it in a Views. I would like to rank the organic groups according to the number of Likes clicked for each... I figure out I would need some kind of integration with Facebook... Is there any kind of module that will allow an intregration between Drupal and Facebook for this specific functionality? I have been using Janrain for logging users, but as far as I know, it won't provide this kind of integration I am talking about... Or maybe some Views-Facebook, or even Flags-Facebook integration where I could associate Likes with flags for a certain item...

Thank you.

1

This question recently came up at work (small world), my thoughts:

  1. Render the Facebook like button using the XFBML version of the button
  2. Attach a handler to the click event (see the docs)
FB.Event.subscribe('edge.create',
  function(response) {
    // do some AJAX stuff here
    alert('You liked the URL: ' + response);
  }
);

In the above callback, fire an AJAX request back to drupal, to update either a custom table, or alternatively you can use the core statistics table. If you wish to use the core statistics table (or even create your own table) you can leverage the code from my module https://drupal.org/project/statistics_ajax

One advantage of using core statistics, is that it has views integration out of the box, although in saying that writing custom views data sources for your table is easy too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.