I’m building my personal page right now, and since I write 2 blogs of my own (with one more coming up) and contribute to 3 other blogs I thought it would be a nice feature to have a list of my most recent posts on my personal page. You could of course always update the list by hand, but how much easier it would be to get it done by a script. It turns out that this is harder to do than it sounds, but a tool I found, called Magpie RSS makes the job easy (or easier, rather).
If you want a simple job done quickly then download the tarball file (for Windows users, I know Tugzip will unpack it for you) and upload the four .inc files and the extlib directory to your server. You then just place some simple php code where you want the list and off you go.
There is one option that I found really useful, namely that it doesn’t only understand a set number of tags. As long as they are in the following two forms Magpie will understand them. <field_name>value</field_name> <namespace:field_name>value</namespace:field_name> This is great if you need some customization, let me show you a quick example of what I needed and did.
Since on my upcoming home page I want to showcase my articles, I can’t just pull feed items from gHacks for example, since this would include Martin’s posts too. The fact that Magpie understands just about any tag came to my help though, along with a php if statement. The gHacks feed has a creator tag (<dc:creator></dc:creator>), which shows the author of the post. All I needed to do was to set Magpie to only show the posts where the creator is “Daniel”. Here’s the code.
$rss5 = fetch_rss( 'http://feeds.ghacks.net/ghacksnet' );
$items5 = array_slice($rss5->items, 0, $num_items);
foreach ( $rss5->items as $item ) {
$creator = ($item['dc']['creator']);
$href = $item['link'];
$title = $item['title'];
$created = $item['created'];
if ( $creator == ‘Daniel’ )
{echo “<li><a href=$href>$title</a> $created</li>\n”;}
}
I’m very far from being a php expert, I just used what I found on forums and websites, so please forgive the lack of explanation, I’d rather not say anything than say something incorrect. My goal is to show you how simple Magpie is, using just a few lines of code, you can create aggregated RSS feeds for yourself without the hassle of third party widgets, which are mediocre at best. You can customize it any way you want, to show you only titles, the full posts, just the categories, etc. Take a look at the How-to section for some cool examples.
Related Posts

3 Users Commented In This Post
Subscribe To This Post Comment Rss Or TrackBack URL