Web

Tweet Roulette

Screenshot from Tweet Roulette

I’d been wanting to do something with the Twitter API for awhile now, but never managed to come up with a good enough idea to start developing. But once chat roulette got popular, the idea of randomly connecting to content made me think about how to use the same idea for Twitter.

Original Idea

The first thing I thought of was an app that randomly selects tweets and displays them. But I realized that you can get the same result by looking at the public timeline. It updates so frequently with tweets from all over the world, that just looking at it is practically the same.

So I thought about what other content is accessible through Twitter. I did a little research and found that not many applications take advantage of the links that get added to people’s tweets. So, I decided to build one that did.

Another Idea

Tweet Roulette takes the latest 20 tweets from the Public Timeline, and searches the text for any links. Anywhere from one to six links are then displayed anonymously for the user to click on.

Once you click one, the target link opens in a new tab, and the information from the tweet that the link came from is added to the main page. That way, when a user finds content they like, they can check out the user who tweeted it, or go back to the link later. Once all the links are clicked, you get the chance to “reload” and pull links from another 20 tweets from the public timeline.

The core program of Tweet Roulette is built entirely in Javascript, parsing the JSON the REST API returns and converting it to markup. One of the challenges in building this app was to deftly manipulate the strings that resulted from parsing the JSON. Strings are immutable in Javascript, so it took some variable juggling to parse out the links and then index them in such a way as to keep them well organized with the arrays holding the tweet information. I ended up using a series of arrays with identical keys to keep all the tweet information organized. I also used an array of indicies to serve as a key to translate between the arrays of tweet info (which always have a length of 20) and the array of links (which can be anywhere between 1 and 10).

Looking Forward

Future iterations of the app will include a place to log in using your twitter account, so you can easily re-tweet content you like, or even get random links from the people that you follow instead of the public timeline.