I am trying to record whenever a user clicks on Facebook Like button. Facebook documentation even specifically mentions this possibility:
“suppose you want to record Likes in your database whenever a button is clicked”:
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
It then tells you to “replace the alert() with your handling code.” Is there a proper way to create this handling code? How would it be called? I tried searching for some easy solution, but haven’t been successful. The problem is I am not familiar with JavaScript, but it shouldn’t be this hard to find what I presume is a one-line solution.
UPDATE: I understand that I have to call a separate script to actually interact with the database. I am just not sure how to call it exactly and if the Facebook JavaScript SDK provides any assistance with that. Based on the first answer I received, I should use something like jQuery, but that seems a bit of an overkill to me. Am I wrong in that assumption?
You will need more than one line, because you will need a database to record it in as well. You would use an ajax call to a page you have setup to record the click event. The easiest ajax call to setup is jquery’s IMO. http://api.jquery.com/jQuery.ajax/ But you still need something to submit to on the server side to record your click, such as an asp or php page with a sql or mysql database, or even a text file on the server.