Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect when user "clicks" the Facebook like button

Is it possible to detect when someone clicks the like button "and before the like action really occurs", i.e. same as onSubmit JS event, it detects when the user submit the form before it even get submitted, giving the ability to process/run some code before it do so.

Usage:
I am trying to implement a Web 2.0 page where all the action happens in one page, so depending on the user actions the content of the page would change "But not the meta"

So my question is, can I detect when the user "clicks" the like button so I can "load" the meta of the current page before the like action really happens?

P.S, I do know that it's not a big deal to load the meta as it's less than 1KB and won't have any effect, however I am just curious if there is any way/ work around to do so.

like image 897
Mohammed Ibrahim Avatar asked Aug 29 '11 20:08

Mohammed Ibrahim


People also ask

What happens when you push the like button on Facebook?

Clicking Like below a post on Facebook is a way to let people know that you enjoy it without leaving a comment. Just like a comment, anyone who can see the post can see that you liked it. For example, if you click Like below a friend's video: People who can see the video will be able to see that you liked it.

How Facebook Like button works?

When a user clicks the like button, the content appears in the News Feeds of that user's friends. The button also displays the number of users who liked each piece of content, and may show a full or partial list of those users.


1 Answers

You can subscribe to an event that will notify you when the user likes something - however this will fire after the action. This is documented at: http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

An example would be:

FB.Event.subscribe('edge.create', function(response) { alert('You liked the URL: ' + response); /* check the response here to see if it's your URL */ });

You could attempt to intercept the action but why would you want to wait to add the meta? Do you mean the open graph headers? Facebook scrapes these every 24-hours, not for each unique like event. Also it would most likely be against Facebook's terms to intercept/alter the like action, as you'd be interfering with their established and expected guidelines.

like image 54
Antonelli Avatar answered Sep 22 '22 15:09

Antonelli