Last active
February 13, 2016 22:32
-
-
Save abronte/4402663 to your computer and use it in GitHub Desktop.
Facebook like/unlike event binding http://thefacebookdev.com/2012/12/facebook-like-button-events/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Like Test</title> | |
</head> | |
<body> | |
<div id="fb-root"></div> | |
<a href="http://thefacebookdev.com/2012/12/facebook-like-button-events/">Original post</a> | |
<h1>Hello World</h1> | |
<div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.Event.subscribe('edge.create', function(response) { | |
console.log(response); | |
alert('Thanks for liking!'); | |
}); | |
FB.Event.subscribe('edge.remove', function(response) { | |
console.log(response); | |
alert('Sad to see you dont like me :('); | |
}); | |
}; | |
(function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) return; | |
js = d.createElement(s); js.id = id; | |
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment