Take me HOME
RSS Gets SimplePie
Tuesday, March 01, 2011 07:18 PM

Some of you may have noticed that the data feeds from Slashdot and The Register were getting old.  Very old... in fact, several months old.

This was due to a problem with the system that pulls feeds (RSS) and stores them in a database, known as CS-RSSDB.  The system broke following an upgrade to the internal XML parsing system (CS-PHPXML) that is used on the site for configuration, AJAX requests, and various other things.  I tried in vain for a long time to get the script to work by forcing it to use the older version of XML parser, which at least allowed retrieval of the SlashDot feed.

I tried to fix the system to follow the new XML parser, but found that it was seriously broken.  So broken, in fact, that it would require a fairly significant overhaul so that it would once again be able to pull basic data out of the feeds.  I just about gave up... then I found SimplePie, an RSS framework that was just as easy to implement as it sounded.

I found it after getting frustrated at the idea that I had to write from scratch every piece of code that powers CrazedSanity.com.  Every piece might not seem like much, for what seems like such a petty website, but it is actually quite an undertaking.  You might not realize it, but CrazedSanity.com uses many different systems/frameworks:

  1. Content (cs-content; a content management/templating framework)
  2. XML Parsing (cs-phpxml; for parsing XML, a major part in some Web 2.0 things like AJAX, RSS Feeds, and site configuration)
  3. CLI Logger (cs-clilogger; a system for logging the output of command line scripts, such as those that download new RSS feeds)
  4. Multi-Thread (cs-multithread; a system for handling communication between multiple processes, used for running multiple simultaneous background scripts)
  5. Battle Tracker (cs-battletrack; a system used by the Table Top Online Role Playing system, "TTORP", for storing Dungeons & Dragons character sheets)
  6. Web Application Libraries
    • database abstraction layer (for putting data into the database and getting it back out)
    • logging activities (page views, errors, etc)
    • database storage of sessions
    • web application upgrade system, for handling code + database upgrades seemlessly

Anyway, I started to feel like I was suffering from the "not written here" syndrome, a problem the befalls developers wherein they basically won't use any code not written by them.  That, coupled with the idea that I had to spend a ton of time rewriting something just to get it working again, made me feel like there just had to be a pre-written alternative out there.  Something that could just parse RSS feeds without all the fuss (trust me, XML of any kind in PHP, even RSS, is painful)... then I found the SimplePie system.

I read the instructions, even downloaded it, and started to feel like I was being mislead.  Like the code just was not as simple as it implied, and that the only way I'd be able to do what I wanted to do would be writing my own.  Have I said that enough yet?  Have I mentioned how truly daunting that task felt?

Anyway, after figuring out how their demo code ran, and ripping out a bunch of stuff that I didn't need, I found that I could get my RSS system running again really quickly with virtually no hassle.  Amazing.  I think it was the first time that I ever found code written in PHP that was actually as useful as it claimed to be.