del.icio.us feed
I had been thinking for a while that I’d like to incorporate some quick links in the sidebar to things that I’ve read and enjoyed, but I was still deciding on the best way to do it. There are some nice WordPress solutions, like markku’s excellent wp-recent-links, but I was feeling exceptionally lazy and thought that there must be another way to do it.
Then I remembered the service which allows you to quickly mark and categorise links, and display them publicly: del.icio.us. It’s really easy to set up an account, and you can see my page here. There’s also an easy method (using a query string) to get a raw HTML fragment containing the last x links in your feed, which you can then include in your blog page.
So, I put a bit of PHP in my sidebar to pull in the last 10 links. You should be able to include HTML files from remote sites using:
include 'http://somesite.com/file.inc';
but it seems that my hosts don’t have the allowurlfopen option enabled, so I had to think of another way to do it.
I found this code in the Programming PHP book:
function include_remote($filename) {
$data = implode("n", file($filename));
if ($data) {
$tempfile=tempnam(getenv("TEMP"),"inc");
$fp = fopen( $tempfile,"w");
fwrite( $fp, "$data");
fclose( $fp );
include($tempfile);
unlink($tempfile);
}
return FALSE;
}
include_remote("http://somesite.com/file.html");
This works very nicely when passed a formatted URI to my del.icio.us feed.
Update: Jens pointed out in the comments below, that such frequent fetching of the feed might violate the terms of service. At the very least, it isn’t very efficient or polite. So here’s another solution—I’m now fetching the feed like this:
wget "http://del.icio.us/html/bsag/?count=10&extended=body
&tags=yes&tagsep=|&rssbutton=yes"
-O /LOCAL_PATH/delicious.html
This should all be on one line. I run this command via cron every 6 hours, and then just include the local file delicious.html in the page.

1
ooooh, that’s hot! thanks for the tip.----- It’s cool, isn’t it? I’m really enjoying del.icio.us. Apart from anything else, it’s a place that I can store things I want to go back and read before I forget. Bookmarks in the browser aren’t good for that.
by bsag @ 17/04/2004 5:05 pm • Permalink •
2
Neat! I’ve been using del.icio.us for a while, but didn’t know about this particular trick – I’ve stolen it for my brand-new blog (except I had the luxury of simply using include( ).)
But … isn’t this against del.icio.us’s terms of service, where they say that anything that hits their site once per hit of your site constitutes abuse? I’ll have to dig out my PHP manual and rig up a function that caches the HTML, only updating it once a day or so.
(Also: I dig your real-time preview! I’ll have to look at the code behind that.)
by Jens @ 18/04/2004 2:04 am • Permalink •
3
Jens: I had interpreted that line in the Terms of Service as applying to the API only, but you’re right—it isn’t efficient or polite. I’ve updated the entry now with a new method (pulling the file in with wget by a cron entry, and then including the local file). There are probably fancier ways to do it, but this works fine.
by bsag @ 18/04/2004 9:05 am • Permalink •
4
I don’t know if it’s better or worse [or even breaks any terms of service], but Richard’s got an alternative method.
by David @ 19/04/2004 8:04 am • Permalink •
5
David: As you might have noticed, I’ve just tried the method you suggested, and it works really well. It seems to have caching (though I haven’t been able to find evidence of the cache yet, so I’m not sure that’s working), so it shouldn’t hit del.icio.us too hard. Thanks for the link!
by bsag @ 19/04/2004 6:04 pm • Permalink •
6
Another cool service is www.spurl.net - it allows you to compile a list like to your left + recommendations and it compiles all your blogs in a very neat sidebar you can use as your favourites and browse away from. Yet another feature is that it offers to save the sites you mark as is so that you can always return to the same site, especially handy when you’re referencing something for an article or paper.
by MD @ 27/04/2004 9:04 pm • Permalink •
7
Spookily, I had already linked to that in del.icio.us, but it hadn’t appeared on this page yet (I was caching the feed for 12 hours). I had a proper look at it today (I’m about to post about it), and saw that it also interacts with del.icio.us in a very neat manner. So I’ve signed up for an account.
by bsag @ 28/04/2004 5:04 pm • Permalink •
8
Using del.icio.us in the sidebar How I use Magpie, Snoopy, and a custom PHP script to create an "overflow" links bar in the side of my blog.
by gamewhore @ 18/05/2004 11:05 pm • Permalink •
9
[...] The ability to bring your bookmarks out into the open is useful and helpful, absolutely. Here’s an example of someone using del.icio.us to pull their bookmarks [...]
by Bill Lovett, Programmer » del.icio.us: I donâ @ 07/09/2004 1:09 pm • Permalink •
10
[...] e in the kitchen other than watching water boil. so many links, maybe i should just get a del.icio.us feed for wordpress. [...]
by david's blog » Cooking for Engineers @ 09/09/2004 4:09 pm • Permalink •
11
[...] us dans mon blog comme promis il y a quelques jours. Malheureusement le code r�cup�r� chez but she’s a girl ne marche pas tr�s bien ici. Pas eu le [...]
by Ma plage » C’est pas la f�te du slip @ 19/09/2004 4:09 pm • Permalink •
12
[...] s, PHP, Javascript. del.icio.us seems to be the flavour of the month! Bloggers around the world are turning their attention to this amazing system. I’ve been [...]
by dontcom.com » delicious linkage @ 23/11/2004 12:12 am • Permalink •
13
[...] ache the results and handle errors for those times when del.icio.us is pouty. I was using But She’s a Girl’s wget method, but t [...]
by Simple Future » Del.icio.us Cached @ 02/12/2004 3:12 pm • Permalink •
Page 1 of 1 pages