Created
February 9, 2014 15:28
-
-
Save incognitosj/8900652 to your computer and use it in GitHub Desktop.
twitter tweet and facebook like callbacks
This file contains 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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title> | |
FB like | |
</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<script type="text/javascript"> | |
var page_like_callback = function(url, html_element) { | |
console.log("fb like callback"); | |
console.log(url); | |
console.log(html_element); | |
} | |
var handleTweetEvent = function() { | |
console.log("tweet callback"); | |
} | |
function sbscribe() { | |
FB.Event.subscribe('edge.create', page_like_callback); | |
twttr.events.bind('tweet', handleTweetEvent); | |
} | |
</script> | |
</head> | |
<body onload="sbscribe();"> | |
<div id="fb-root"></div> | |
<script> | |
(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&appId={yourAppId}"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
</script> | |
<div class="fb-like" data-href="{youUrl}" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div> | |
<div><a href="https://twitter.com/share" class="twitter-share-button" data-text="{tweet}" data-size="large" data-hashtags="{hastag}">Tweet</a> | |
<script> | |
! function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0], | |
p = /^http:/.test(d.location) ? 'http' : 'https'; | |
if (!d.getElementById(id)) { | |
js = d.createElement(s); | |
js.id = id; | |
js.src = p + '://platform.twitter.com/widgets.js'; | |
fjs.parentNode.insertBefore(js, fjs); | |
} | |
}(document, 'script', 'twitter-wjs'); | |
</script> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment