Consuming a Google Reader Shared Items Page with SugarCRM
This evening I began evaluating a fresh install of SugarCRM 5.2.0a. A feature that caught my interest was the ability to consume feeds via the RSS module. Having various feeds available to me while working in a CRM would be great, so I decided to try it out.
The first URL I tried was the the ATOM feed of my Google Reader Shared Items page. It didn’t work.
What happened?
Instead of seeing the items in my feed listed after I submitted the URL, I was presented with nothing! Nothing in the error logs, no failure message on the page, just silence. This sort of thing really drives me nuts in an application. Is it so hard to detect an error condition?
Some Googling around for a solution led me to vague posts from others having similar issues. I guess the module is extremely picky about the type of feeds it will aggregate. User reports indicated that only RSS 2.0 content can be parsed, leaving the various ATOM flavours out in the cold.
Ok, I thought, if I can convert the Google ATOM feed into RSS, I should be all set!
Converting ATOM to RSS.
I found few options here.
2rss.com has an Atom2RSS service that claims to do what I need, however plugging in my Google Reader URL gets me nothing. Just like SugarCRM, no output. C’mon guys, really?
Moving on in my searches, I didn’t find much else, except for the option of rolling my own.
To this end, I found an interesting bit of XSL code at http://atom.geekhood.net/ which when applied to the ATOM doc should transform it to an RSS feed readable by SugarCRM!
I copied and pasted the sample PHP code provided, but ended up getting a string of errors:
xsltExtFunctionTest: PHP Object did not register PHP functions xmlXPathCompiledEval: evaluation failed
The solution to this was a missing call to the registerPHPFunctions method of the XSLTProcessor.
Solution
Here is the code I ultimately used to get it working:
$chan = new DOMDocument(); $chan->load('URL TO ATOM FEED'); $sheet = new DOMDocument(); $sheet->load('atom2rss.xsl downloaded from http://atom.geekhood.net/'); $processor = new XSLTProcessor(); $processor->registerPHPFunctions(); $processor->importStylesheet($sheet); $result = $processor->transformToXML($chan); echo $result;
As a quick test I copied and pasted the output of the above script into a static file on my webserver. Submitting the URL into the SugarCRM RSS module, I finally saw the content.
Wrapup.
In a perfect world, issues like this wouldn’t arise because coders would properly check for error/failure conditions in their code. Not to mention document things a whole lot better. On the subject of feeds and nice documentation, I want to give a shout out to the guys (Geoff and the two Ryans) at SimplePie.org. They’ve created an amazing PHP library capable of gobbling up just about any feed you throw its way. It’s also remarkably well documented. Keep up the good work, guys!
As always, let me know if you have any questions or problems with my solution here and I’ll be happy to help!

Based on the writeup here, I’ve launched a web site offering the ATOM 1.0 -> RSS 2.0 conversion as a service.
Check it out! http://atom2rss.info/
fdask
9 Mar 09 at 10:11 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>