Fri 19 Nov 2004
I’d been thinking for a while about the links interface in WordPress. It wasn’t as flexible as I wanted it to be so I decided to try to write a WordPress plugin using Magpie to use my del.icio.us feed. After a few hours of fudging around with it I was getting somewhere. Then I broke it and couldn’t rollback. (There’s a lesson.) Anyway, rather than carry on with the plugin, I hacked the index file like this (ala Richard Eriksson, via Jon Hicks):
<!-- Joe's Delicios Links -->
<li>Joe's del.icio.us links
<ul>
<?php
require_once ("wp-content/plugins/magpierss-0.61/rss_fetch.inc");
$yummy = fetch_rss("http://del.icio.us/rss/nzjoe");
$maxitems = 10;
$yummyitems = array_slice($yummy->items, 0, $maxitems);
foreach ($yummyitems as $yummyitem) {
print '<li>';
print '<a href="';
print $yummyitem['link'];
print '"';
if (isset($yummyitem['description'])) {
print ' title="';
print $yummyitem[’description’];
echo htmlentities($yummyitem[’description’]);
print ‘”‘;
}
print’>’;
print $yummyitem[’title’];
echo htmlentities($yummyitem[’title’]);
print ‘</a>’;
print ‘</li>’;
}
?>
not pretty code, but it works. Now I just have to remember to give all of my delicious posts meaningful titles and descriptions.
Of course this could be used for any RSS feed. And you can also give delicious links a specific tag for when you want them appear on your site and point it at the feed for that delicious tag. (e.g http://del.icio.us/rss/myname/mytag)
UPDATE 2: Contact me for the latest version. WP does funny things with the single and double quotes
2 Responses to “Delicious links”
Leave a Reply
You must be logged in to post a comment.
November 22nd, 2004 at 19:32
I’ve just done the exact thing with my blog. I made use of a PHP API i found on the del.icio.us API mailing list.
That api allows for easy access to the raw data. Its got method calls for everything on the del.icio.us api and also includes some error checking, etc. Very very nice!
Here’s the code I used to create an include of all my links. I use a cron job to create a delicious.inc file every 6 hours that i simply include in the document (as not to hammer their server).
November 23rd, 2004 at 06:57
I thought about doing it that way, but then decided that I preferred Magpie’s caching better, and I don’t need to mess around with cron. Also I thought that i could turn it into a plugin for WP easier. Can’t be bothered now though, too much other stuff to do.