or link to any RSS Links via PHP.
On my home page I have a section near the bottom that has a link to my latest blog entry. This didn’t use to be automatic for me. I used to manually edit every link and title to my latest blog entry to keep that link accurate. That gets boring and really old after a while, why not make it automatic.
I tried to do it via SQL but could never get it to work the right way. Well there are many solutions out there. If you can run PHP files than its even easier via Magpie’s RSS Parser.
Download the parser and create a directory on your server that contains the following files:
That’s all you need. Notice extlib is a directory containing Snoopy.class.inc.
Now create a PHP file that includes the rss_fetch.inc. Examples are available on Magpie’s Page. MagpieRSS is compatible with RSS 0.9 through RSS 1.0. Also parses RSS 1.0’s modules, RSS 2.0, and Atom. (with a few exceptions)
$url = ‘http://cyberredneck.org//?feed=rss2‘;
$rss = fetch_rss($url);
//echo “Site: “, $rss->channel[‘title’], “<br>”;
$item = $rss->items;
$title = $item[title];
$url = $item[link];
echo “<a target=_blank href=$url>$title</a></li><br>”;
This PHP code will parse my RSS Feed, grab the top entry and produce a link that opens in a new page. For optimum stability I always suggest using relative links, absolute links can fail especially if you have multiple domains like I do.