Magpie RSS
The alpha release of my RSS parser for PHP is out. Called Magpie, it attempts to make including the results of an RSS feed in a PHP page simple, and straightforward.
To me, simple and straightforward means:
- not haveing to setup an external process (cron) to fetch feeds, but not adding the wait for fetching and parsing the RSS feeds to every page view
- not haveing to worry about which version of RSS you’re parsing, but not losing the richness of any version
- not haveing to negoiate PHP’s object syntax, when many people are still struggling with functions. (PHP’s fault, not theirs)
But as the my motivation for writing this was to parse Protest.net’s event feeds which use the rss events module I needed a solution that could handle RSS 1.0 modules, and give me access to the underlying data, not just a pretty printed version of the feed. The solution. MagpieRSS is an XML (expat) based RSS (RSS .9, RSS .91, RSS .93, RSS 1.0) parser for PHP. It automatically wraps the parser, and a cache system, behind a simple, one function interface.(though each piece is independent and can be used separately) Modules and namespaces are supported by being tooked into their own hashes, unrecognized tags are accepted on face value and included in the results. Magpie returns its results as a PHP data structure, useful for iterating over, and passing to template systems like Smarty or as a simple PHP object for future use.
MagpieRSS currently makes no attempt to dictate how you want to format, or display your RSS feeds (a key failing amont existing solutions), and a perfectly valid use would be to just use the RSS parser (rss_parse.inc
) to store items from a feed in a database. However Magpie assumes you’ll want to be displaying the results of parsing and documentation and examples both with templates, and vanilla PHP are coming soon.
And I need to go scare up some coffee, as there are a hell of a lot of run on sentences in this entry.
Also, after I announced MagpieRSS on the RSS-DEV list, justin klubnik accouned class.feed another PHP RSS parser, and the only other one I’ve seen, that I would reccomend.