archive my tweets

I liked vrypan’s idea about keeping control of your tweets.
But I wanted to do it «the other way around».
Keep using the twitter interface, but archive a copy of my tweets in a dedicated wordpress blog.

So I found a wordpress plugin that does that:
Twitter Tools

I also wanted to populate my blog with my older tweets.
So a bit of Net::Twitter::Lite and WordPress::API thrown in a few lines of perl code, did the trick!


#!/usr/bin/perl
use Net::Twitter::Lite;
use WordPress::API;
use Unicode::String;
use utf8;

my $nt = Net::Twitter::Lite->new(
 username => "twitter-username", password => "twitter-password");
my $w = WordPress::API->new({ proxy => 'http://stsimb-tweets.irc.gr/xmlrpc.php',
 username => 'blog-username', password => 'blog-password', });

eval {
 my $statuses = $nt->user_timeline({ count => 100, page => '1' });
 for my $status ( @$statuses ) {
   print "$status->{id} $status->{created_at} $status->{text}\n";
   my $tweet = Unicode::String::utf8($status->{text});
   my $post = $w->post;
   $post->description("$tweet");
   $post->dateCreated("$status->{created_at}");
   $post->save;
 }
};
warn "$@\n" if $@;

So now I have most of my tweets at http://stsimb-tweets.irc.gr/.
It’s my own tweetbackup service :-)