Building TwitterVote

So now that we know a little bit about Twitter, let's discuss the application we are going to build. This web-based application will poll your own user account looking for a keyword that determines a poll has started and find the valid parameters for that poll (either a numeric value or a choice of text values).

The application will then poll the list of replies to your Twitter account and determine which of those are valid poll responses. These responses will be tabulated and displayed on a web page.

Twitter: Under the Hood

Twitter exposes its API via Representational State Transfer (REST). Simply, this means the API is exposed via the Web and will return a chunk of data in a defined format. The following are some examples from Twitter's API. Note that the format can be XML, JSON, RSS, or ATOM, depending on the API. To switch formats, just change the .xml extension to .json, .rss, or .atom to retrieve data in the specified format. User tweets: http://twitter.com/statuses/user_timeline/coding4fun.xml

The Twitter API

Twitter's API model can be found at http://apiwiki.twitter.com/. The supported calls you can currently make against the API are listed in Table 6-1.

Table 6-1. Twitter API methods

METHOD TYPE

METHODS

Status methods

public_timeline, friends_timeline, user_timeline, show, ...

Get Coding4Fun now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.