Created
November 27, 2012 20:44
-
-
Save andrew-aladev/4156888 to your computer and use it in GitHub Desktop.
proper twitter callback
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
<!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> |
Thanks so much for this. You saved me a ton of headache!
Thanks for your time in deciphering this.
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
define share_window at the start of script, otherwise I get an error that share_window is undefined.