Twitter is fun, and you can play with it. In spite of the multitude of
Twitter clients, some of which can keep some sort of archive of what I’ve
tweeted, I want to collect my tweets and archive them independently of
the client I’m using.
I’ve knocked up a small Perl program which uses the Twitter API to grab
my so-called time line in JSON format. It then stores the individual
tweets in a small SQLite database – nice and lightweight.
Start off by creating the database, which I’ve called tweets.db:
The database table is trivial; its definition is in tweets.sql:
Now comes the small program, which retrieves my time line from Twitter, parses
through the JSON format and inserts my latest tweets into the database.
Each time the program runs, it determines the last tweet identifier I
received, and asks Twitter to return tweets that were submitted since then.
(I’m being nice to Twitter in doing so.)
Tweets are stored in the database table, and I can do something with those
sometime later, for example:
Remember, that you’re not allowed to invoke this program terribly often:
Twitter rate limits access to its servers. I run it once an hour from