Let's play Twitter Roulette

This is one of these things that should exist, but didn't. An application to pick a random tweet, given a search expression:

The Twitter Roulette in action

It's extremely useful for IT events and promotions, but after googling for all the possible combinations of "Twitter Draw", "Twitter Roulette" and "Twitter Lottery", we finally gave up. There was no such thing.

Actually, there are good reasons for this:

  • There is no official JavaScript client library for Twitter, only widgets.
  • To use the Twitter API, the user must validate using OAuth1. That's a though barrier of entry for many casual developers.
  • The Twitter Search API v1.1 does not support JSONP.
  • The JSON API does not support CORS. This looks like a bug, when you compare with Github and others.

This makes it impossible to make invocations directly from the browser, but having a server is not a convenient solution for everyone, certainly not for us. We wanted to do this using a 100% HTML + JavaScript solution.

So we rolled a Chrome extension, since it can specify its own CORS restrictions. It took us 48 hours to put something together, not bad considering that this is our first Chrome extension. It requires the credentials from an application registered at apps.twitter.com. Just register anything, create an access token and copy these four values into the extension.

If you want to give it a try, you can install it from the Chrome Web Store and drop your cold buckets of feedback on Github or Twitter.