How to catch action from Facebook 'Like' button - facebook

Is there a way to catch event of clicking Facebook like button? I don't want to integrate my app with Facebook, just need to count clicks of 'Like'. Tried :
$('.fb_iframe_widget').click(function(){
alert("clicked");
});
but without any luck. If there is no way of doing this will I be able to count likes of particular pages when synced with FB API ?

You must use the xfbml like button rather than the iframe button. After you switch that, do the following:
FB.Event.subscribe('edge.create', function(response) {
// user clicked like button!
});
The facebook event "edge.create" is called when a like button is clicked. I have no idea why it is named that, but that will do what you are looking for.

If that doesn't work, then I think you'd be out of luck, as you can't do anything else because of same origin policy.

Related

how to check who and when clicked facebook like button

I using this to check how many likes are on my website
http://api.facebook.com/restserver.php?method=links.getStats&urls=http://mywebsite.pl
My Question is:
How to check who and when clicked facebook like button on my website?
There is no way to identify users who clicked a Like Button on your external Website, for privacy reasons. You can only see friends who liked the same URL by setting the "data-show-faces" flag in the Like Button Plugin.
You can subscribe to the edge.create event if you want to know when it gets clicked, but this still does not return WHO clicked it: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe

Count facebook like from our page

We want to give our site visitor option to like our Facebook page from our website. However we want to track the "count" of how many like we get from this page. It is indeed our campaign page and we want to track how many visitor we have verus how many like we generate.
I did google and maybe I don't know how to search it, but all I got is general count of like or how to get like button. But my need is little specific, we just need how many like our campaign generate. Period.
You can do some analytics at your end-
The XFBML and HTML5 versions of the button allow you to subscribe to the edge.create event in the Facebook SDK for JavaScript through FB.Event.subscribe. This JavaScript event will fire any time a button is clicked.
edge.create is fired when someone clicks a like button on your page to like something.
edge.remove is fired when someone clicks a like button on your page to unlike something.
Example-
var page_like_or_unlike_callback = function(url, html_element) {
console.log("page_like_or_unlike_callback");
console.log(url);
console.log(html_element);
}
// In your onload handler
FB.Event.subscribe('edge.create', page_like_or_unlike_callback);
FB.Event.subscribe('edge.remove', page_like_or_unlike_callback);
And some other ways mentioned in the FAQ section of the documentation: Like Button

how to subscribe to facebook like event for iframe Like method

I have integrated facebook Like button in my facebook application using the iframe method.
I am not able to subscribe to Like event, even using
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You just liked '+href);
});
I understand this works for <fb:like .. but this method opens a comment pop-up whenever Like button is clicked, which I don't want to happen. If this can be avoided (making it work like iframe method), I am happy using this method.
I referred to https://stackoverflow.com/a/3718992
but not sure this is the issue.
Can anyone please guide?
Thanks
Simply stated, is it possible to use
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You just liked '+href);
});
for iframe method of integrating Like ?
Well, if it opens a pop-up it means you are subscribed.
Edit the second line in the javascript code to call action after user clicks like (now it calls pop-up).

Facebook to check "like" on fan page

I noted there is a link to generate "like button" code at :
http://developers.facebook.com/docs/reference/plugins/like/
However it wasn't act as the top of fanpage "like" button which will redirect users to another page if I setup to check the pages liked or not. Is there any other way that I can generate the button as the top of fanpage "like button" behavior or way of using the recent plugins like and redirect users once they liked the page?
Eric.
If you are using a XFBML like button then you can use the JavaScript SDK to detect likes by subcribing to the edge.create event using FB.Event.subscribe
FB.Event.subscribe('edge.create',
function(response) {
// Do redirect here
}
);
For more information on the Facebook JavaScript SDK please go here:
http://developers.facebook.com/docs/reference/javascript/

Facebook: Get when user clicks like button on fan page

I have created an app that will be used as a tab on my company facebook fan page. I have a new requirement to capture when the user clicks the like button on the facebook fan page and hide a portion of the app page (within the iframe) when the event fires. Although the like button is on facebook's page, is there a way to capture the click event of the like button (ie: javascript sdk) within my app iframe so I can hide appropriate elements?
Like this .... http://www.facebook.com/redbull
Thanks for any and all advice,
B
I found the answer...
How to detect Facebook Like button pressed and trigger event?
I checked the incoming request for fb_sig_is_fan.
I am afraid that this is not possible. Also it makes no sense! because Facebook will reload the page once you click on the like button!