Uncategorized

Tumblr Integration in PHP4

Turns out: totally not worth the effort in this case.

I’m working on an NPO site right now whose code concerns me more and more as I get into it. I’m new to the group and don’t have a whole lot of time to devote to the site, but one of my first tasks was to get the owner’s recent Tumblr posts to show on the homepage.

Cool beans, easy cake. The API’s well-documented and clean (although it has an annoying amount of variation in post types). I quickly Bing (binging it, baby!) to see if I can find an existing implementation accounting for all those variations, and find phpTumblr.

Hawt. 1-2-3-go. I set it up to just barf out the array it produces so I can handle presentation, throw it up in a hidden area on the web server, and get… an error:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in
/path/tumblr/phpTumblr/clearbricks/common/lib.l10n.php on line 40

Hmm. Check the code… The library’s solid. PHP’s choking on a static variable definition. My stomach sinks.

A phpinfo() reveals PHP 4.4.4. Like, real deal. In the year 2011. Surely this is a joke.

I cruise around the server and find only PHP4 excutables, no PHP5 installation at all. I don’t know who exactly maintains (and I do mean “maintain”) the server, and I really don’t want to get into it at the moment–the owner and I need to establish some kind of progress after all the delays in getting this (larger-scale) ball rolling.

I putz around a bit with PHP4 methods of XML parsing, and discover that not only does this server not have DOM XML, as far as I can tell, it doesn’t have any XML libraries installed.

I can’t… I just… What?

Nope. Not playing this game. I refuse to spend hours working around a 5-year old server setup in order to get some blog posts to show on a page.

I write up a snippet of JavaScript to handle basic, normal posts using the JSON interface, and get the posts on the homepage in no more than 10 minutes. It’ll take me 30 more minutes to go back in and account for the rest of the post types, at most. I’m seeing no noticable load time increase on the page, in part probably due to the loading of Flash elsewhere on the page.

A win-win, for now.