views:

61

answers:

2

I would like to build a Facebook Like-functionality for a video competition (currently not connected with Facebook in any way) where the like button gets the total amount of likes as a callback when clicked so that I can save it in my database and use as the primary voting system.

Is it possible to build this solution, preferably in Javascript?

EDIT:

What I want to do is

  • Implement a "Like"-button
  • When clicked, like request is sent to Facebook
  • When the request is processed, a callback function is activated.
  • The callback function gets the total amount of likes as a parameter
A: 

I don't understood question. But what the problem?

Click handler send ajax request -> server side code return total amount -> ajax request callback drow it.

Falcon
I updated the question to be clearer.
Christoffer
it is Facebook or your platform?
Falcon
My platform, I have an application id to use with the Javascript SDK but my platform is in no other way connected with Facebook. I just want to use "Like" as a voting system and I need to save the total amount of likes in my database in order to perform sorting on votes.
Christoffer
+2  A: 

Something along those lines:

FB.Event.subscribe('edge.create', function(response) {
  // user clicked like
  var query = FB.Data.query('SELECT like_count FROM link_stat WHERE url="http://example.com/current_url"');
  query.wait(function(rows) {
    alert('number of likes ' + rows[0].like_count;
  });
});

edge.create is an event that should be fired when a user likes a page (see here). For some reason I couldn't make it work a few months ago though.

serg