protocol7 archive
4 April 2010

Syncing tweets to Wordpress

The way old tweets just go missing worries me. This is my first tweet, not available on Google Search (at least not when writing this post). While my average tweet isn’t of much value, over time it builds into something I want to own and have around forever. And I want Google and the others to index it. As usual, this means I want keep it on my own domain. So, I had to set up some form of sync to my protocol.com domain. Since I’m a WordPress fanboy, keeping these in WP made sense to me. Turns out, it was simpler than I expected.

Getting my tweets distills down to two methods: getting the archive and continuously getting the new ones.

First, I run backupify to keep a basic backup of my online stuff, among that, my twitter stream. Highly recommended. backupify keeps my entire Twitter history as an Atom feed. Now, WordPress still does not support importing posts from Atom, so I had to convert the feed into RSS 2.0. A simple XSL-T stylesheet (available on my GitHub) took care of that. Please note that the stylesheet is purpose-made for this conversion, if you want a generic Atom to RSS 2.0 stylesheet, you might need to be a bit more strict, especially on the date formatting.

So, now I had all my tweets as a RSS 2.0 feed. I could start importing this into WordPress. Turns out the import would die after some hundred tweets (perhaps something with my MySQL settings) but since the importer verifies duplicates, I could simple just rerun the job until all entries was imported.

Then, to get continuos synchronization, I use the Twitter tools plugin for WordPress. It will poll my Twitter stream every 10 minutes and create posts for every new tweet. Works as designed.

twitter-tools

That’s it really. I also adapted an existing Twitter inspired template for WordPress to be even better for tweets (don’t show title, don’t show author, permalink post time and so on). And, here we go, all my tweets, ready for indexing and saved for posterity. Now all I need to do is to write something useful that is actually worth saving, but that’s the easy part right :-)

tags: backup - ownyourdata - twitter - Wordpress