No Source Display Fix

April 26, 2005

Dan Nummer emailed two new code suggestions for the feed2js.php. One addresses the trap for missing values for the src= parameter, the URL for the feed. In previous versions, it attempted to do a URL switch to another error message page, but that does not work in the JavaScript output. The fix was to insert a placeholder one item RSS feed that is an error message:
http://feed2js.org/nosource.rss or in the feed2js.php code, modify the error checking code to read:
// ERROR CHECKING FOR NO SOURCE -------------------------------

$src = (isset($_GET['src'])) ? $_GET['src'] : '';

// trap for missing src param for the feed, use a dummy one so it gets displayed.
if (!$src) $src = "http://feed2js.org/nosource.rss";

See it in glorious action. Another problem identified by Dan was when Magpie got a bad feed but still returned some object reference, so he suggested changing the error checking line from:
if  (!$rss) {
to
if  (!$rss->channel['link']) {
Thanks Dan!

Write a comment










Remember personal info?





Spam Prevention Security Code: Enter the numbers you see in the image above