Few weeks ago @imjustcreative mentioned on Twitter that he would like a WordPress plug-in that would scroll (tick) tweets where soultweet is mentioned. As I wanted to do a plug-in for some time, but never had any good ideas, I told him that I'll take up the job. So I started to work on this in my free time.
Before I even started looking at anything, I decided that I want this plug-in to be fast, to work with smallest possible data to save bandwidth and to keep the number of calls towards Twitter low.
First I looked into the Twitter Search API documentation, to see how data can be retrieved from Twitter in Atom or in JSON.
The first idea...
As a JSON document is smaller than an XML document, I decided to retrieve data in JSON. Of course, once retrieved it would be cached locally in a file for some time (5 minutes is my default).
I also wanted to avoid the possibility of the page waiting to retrieve the data from Twitter, so I figured that it would be the best to call it up with Ajax. That way, when the plug-in is called up, it sends an Ajax request to himself, the page continues loading normally and in the background runs the Ajax request.
The draft was there, I looked at the WordPress writing a plug-in page and in a week or so the first version of the plug-in was ready to go out.
I tested it locally on my Windows machine (a basic WAMP setup) and on my Ubuntu machine (a basic LAMP setup), on this server and on another one which has a ton of security limitations (server of my College). I was glad to see that it worked like a charm on all 4 servers. I put up a TickTweet page, and let it out in the wild through Twitter.
The retweet madness started immediately. @imjustcreative, @jonimueller and @bishop1073 downloaded it right away. Soon as they enabled the plug-in, the short and exciting life of TickTweet started to end. Errors, bugs... Joni's server is running on PHP 4, and I had a few PHP 5 only functions. My bad. On Graham's and Bishop's server who knows what went wrong. Graham helped me a lot tracing down the bugs, a few of them were found and squashed, but that was not enough. So I decided to pull back TickTweet, rethink it and possibly rewrite it.
The second idea...
OK, this JSON Ajax thingy won't work. Back to the paper. I started looking at the WordPress core to see what functions and/or classes are available in it for this kind of task... Didn't took me long to find the
fetch_rss() function. Man I was happy to find that! It's using the MagpieRSS and the Snoopy classes to retrieve the data. I figured, those are included in WP's core, they're gonna do the job just fine. So I've rewritten it.
Testing again. The College's server was dropped out right away, no way around that security. On others it worked fine. I tested for a couple of days just to make sure. When I thought it was OK, I've let it go once again. I contacted Joni, Graham and Bishop to tell them that the new rewritten version is out. On Joni's site it worked. Awesome. On Bishop's site worked. Kinda. On Graham's site didn't work. He tried it on another site. Worked. Cool. Finally it works. I was happy.
But not for long. The next day I saw that on my site it's ticking some ol' tweets. What?! Then started the bug hunting again. I looked at each line of code,
var_dumped every variable. No luck. Somehow, all of a sudden, my server is not getting the data from Twitter. No changes on the server configuration, no change in the code, but it just won't work.
The third idea...
The third idea is to leave this plug-in asis, and to stop working on it. It just doesn't pay off. Sure, I could trace down where it hangs on my server, going backwards through the code, but it's just not worth it. Those who are interested in this plug-in, you can find it at the TickTweet page, use it, rewrite it, change it, trash it.