« | Home | »

Improve Your Phplist RSS-to-Email Feature By Using Simplepie Rather Than Onyx

By Greg | July 30, 2007

The phplist mailing list software includes built-in support for RSS-to-email by way of Onyx RSS, a pretty useful chunk of PHP code which is now around 5 years old. However, you can improve your RSS-to-email (and Atom-to-email) capabilities significantly by upgrading phplist to use Simplepie rather than Onyx. It’s new, it’s snazzy, and (unlike Onyx) it’s being actively developed and supported.

Around 5 years ago, Onyx RSS — written by Edward Swindelles — was a great PHP-based RSS parser, and in many ways it still is. Magpie RSS also came out roughly in the same time frame, and while version 1.3 of Onyx RSS was released around a year later, Magpie kept advancing up to version 0.72 in 2005, quickly becoming the library of choice for PHP-based RSS parsing. Despite the superficial difference in version numbers, Magpie clearly had the stronger feature set. Onyx RSS, unfortunately, never was developed any further by its author; in 2003, he relicensed it to use the MIT license rather than GPL, but that’s as far as it went. His website has been gone for quite awhile; following a bereavement in that same year, his site and his work effectively disappeared from the web.

The well known mailing list software phplist has, for whatever reason, continued to rely on Onyx version 1.0 to provide RSS parsing capability and to support RSS-to-email features. Perhaps it’s because the software is mainly developed by just one person (Michiel Dethmers), with only 24 hours in a day, or perhaps it’s because not enough users have asked for more advanced RSS support — beats me. But thanks to Simplepie — a modern package for parsing RSS and Atom with capabilities far surpassing those of any of its predecessors — you can now have modern RSS and Atom support for your phplist installation. Due to the way Simplepie returns information from the feed, you can also benefit from consistent names for the content of different tags (e.g., ‘Author’ or ‘Pubdate’). That means you can use these names in your RSS parsing template (which you specify in the main phplist configuration page) knowing that they will always work, regardless of what sort of feed syntax your list is fetching from, and regardless of whether it is an Atom or RSS feed.

I’ve hacked together some modifications to getrss.php from phplist version 2.11.3 to support Simplepie, and I hope Michiel will consider incorporating them (or something like them) into future stable builds of phplist. (Note that 2.11.3 is not a stable release. I have made and tested the getrss.php modifications under that version, however, because my own installation was suffering too much from bugs in the latest stable release, 2.10.4.) I have been using the modified getrss.php for several weeks now on a site with daily RSS updates to several different lists, without problems of any kind. Your mileage may vary, however!

The modified file requires that you have already installed Simplepie in a suitable location — either in your include path (my own preference) or within your phplist installation itself. If you do not install Simplepie in your include path, you’ll need to modify the include line with the appropriate path to Simplepie. (The source code is all commented — just have a peek.)

In addition, this modified getrss.php includes a fix for a bug in current versions of phplist which prevents RSS items from being fetched for a given list if some other list has already fetched those same items. However, this fix reveals another problem in phplist, which is that if one person subscribes to two different lists, each of which carries the same item, that person will receive the item twice. If you prefer the previous bug rather than the new bug, just back out the bug fix. (This scenario is not as goofy as it sounds, by the way, and contrary to Michiel’s comment when the bug was first reported, it is not merely a case of not being able to use the same RSS feed for two different lists. Sometimes, two different feeds each carry the same item at the same URL — such as two different category feeds in a WordPress installation, where some items appear in more than one category, or a category feed and a main feed. If you use phplist to deliver WordPress posts from anything other than your main feed, you will likely encounter either the original bug or the bug revealed by the bug fix.)

You can download the modified file here:

IMPORTANT: This code is ONLY intended to work with 2.11.3 — NOT with 2.10.4. And as noted above, the modified file requires that you have already installed Simplepie in a suitable location.

The modified code is released under GPL version 2, the same as the phplist package itself.

9 Comments »

Bookmark and Share:

9 Responses to “Improve Your Phplist RSS-to-Email Feature By Using Simplepie Rather Than Onyx”

  1. cyberagency Says:
    August 5th, 2007 at 2:44 pm

    I tested this approach with out success.

    OK Simplepie is a great rss system but when I implement it in phplist 2.10.4 I have no success.

    The getrss page only displays

  2. cyberagency Says:
    August 5th, 2007 at 2:47 pm

    The getrss page only displays a “Parsing http://news.google.be/nwshp?tab=wn&q=&output=rss..” nothing else. Do you have a sugestion ?

    The compatibility_test and demo of simplepie is OK and the path to simplepie.inc is also OK

    Thanks for your feedback

  3. Greg Says:
    August 5th, 2007 at 5:19 pm

    Hi there cyberagency,

    Two things:

    1) The code I’ve modified is ONLY intended to work with 2.11.3, NOT with 2.10.4.

    2) In case you’re feeling extra-extra-brave and are deliberately trying to mix 2.10.4 with 2.11.3 modified, does your Simplepie installation work OK? I.e., have you tested it, and found that all is well with Simplepie, just not with Simplepie working with phplist?

    All the best,
    Greg

  4. Michael Christopher Says:
    September 22nd, 2007 at 4:48 pm

    This is very cool, if I can just get it to work. Been using phplist for 3 years, just upgraded to 2.11.3 and tested. Got SimplePie working. But can’t seem to get the two working together. I edited your getrss.php with my path to simplepie.inc, but no dice. Any chance you could point me in the right direction? I’ll be doing some interesting things with this and will gladly share. Thanks in advance!

  5. Michael Christopher Says:
    September 22nd, 2007 at 4:54 pm

    Oh, one other tidbit. The rss I’m pulling in is just one feed, http://blog.hittransition.com/rss.xml. (An rss 2.0 feed. I could instead use the Atom or rss 1.0 version.)

  6. Greg Says:
    September 24th, 2007 at 9:31 am

    Hi Michael,

    Well, you haven’t given us very much to go on, but let’s see what we can do…

    The first thing I would suggest checking is to verify that 2.11.3 is fully functional with its own RSS parsing: i.e., if you use the original getrss.php file, rather than the modified one, does it handle your feed alright? If you can verify that it works just fine without the changes to getrss.php, that makes it more likely that it’s something in the getrss.php which is causing you troubles.

    The next thing I would suggest checking is to verify that Simplepie is fully functional when you’re calling it from the same location as getrss.php. You might drop a test file in next to getrss.php, for example, and see if it works; if it doesn’t, there could be a problem with the path specified, or with other permissions somewhere in your setup.

    Finally, if phplist is definitely working without the modified getrss.php, and Simplepie is definitely working from the same location as getrss.php, then it’s time to go through getrss.php and check whether anything at all could have been altered in there besides the path (i.e., running a diff comparing the two).

    Beyond that sort of systematic testing and verifying, with the aim of excluding possible problem sources one by one, I’m afraid I can’t offer much more.

    Good luck!

    All the best,
    Greg

  7. weston Says:
    April 2nd, 2009 at 7:49 pm

    I needed to do this recently for my website but found the problem with the feeds itself. And a solution that i came up with was to pass the feed through feedburner and that fixed it and i didn’t have to use your solution

  8. Bill Says:
    March 3rd, 2010 at 6:00 pm

    Thank you so much for this…got it working great with 2.10.10! This would be a great (and easy) addition to the primary source.

  9. Greg Says:
    March 4th, 2010 at 9:26 am

    @Bill — Excellent, I’m glad to hear it!

Comments