Skip to content

Instantly share code, notes, and snippets.

@andrew-aladev
Created November 27, 2012 20:44
Show Gist options
  • Save andrew-aladev/4156888 to your computer and use it in GitHub Desktop.
Save andrew-aladev/4156888 to your computer and use it in GitHub Desktop.
proper twitter callback
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>
</head>
<body>
<script>
$(document).ready(function() {
var url = "https://twitter.com/intent/tweet?" + $.param({
url: "http://www.google.com",
text: "text"
});
$(window).bind("message", function(event) {
event = event.originalEvent
if(event.source == share_window && event.data != "__ready__") {
console.log($.parseJSON(event.data));
}
});
var share_window = window.open(url);
});
</script>
</body>
</html>
@glytch
Copy link

glytch commented Dec 3, 2014

I looked all over the internet for this. thanks.

I'm going to include some stuff that would have helped me find this page via search. twttr event bind intent callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment