Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Last active December 20, 2015 19:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save niraj-shah/6185935 to your computer and use it in GitHub Desktop.
Save niraj-shah/6185935 to your computer and use it in GitHub Desktop.
Tracking tweets using Web Intents and the Twitter API
<!-- Include the twitter JS library -->
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
<!-- Tweet button with just text -->
<p><a href="https://twitter.com/intent/tweet?text=My first tweet using Web Intents">Tweet</a></p>
<!-- Tweet button with link and text -->
<p><a href="https://twitter.com/intent/tweet?url=http://www.webniraj.com/2013/08/08/twitter-api-tracking-tweets-using-web-intents/&text=Tracking tweets using Web Intents:"><img src="https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_48.png" /></a></p>
<script type="text/javascript">
twttr.ready(function (twttr) {
// bind to the tweet event
twttr.events.bind('tweet', function( event ) {
// add ajax call here to store the tweet details
// i.e. increment a counter in your database
console.log( event );
} );
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment