arrow-left arrow-right brightness-2 chevron-left chevron-right facebook-box facebook loader magnify menu-down rss-box star twitter-box twitter white-balance-sunny window-close
Integrating Del.icio.us with your weblog
1 min read

Integrating Del.icio.us with your weblog

As I touched on yesterday, I moved my ‘linkblog’ over to del.icio.us and was working on a way to merge those bookmarks with this site. After thinking about the various ways to do this, I came across an HTML generator on the del.icio.us site. It certainly isn’t the prettiest solution, but I figured it was something I could get up and running in a matter of minutes.

The basic idea is that del.icio.us will return a chunk of HTML as per the arguments you supply it. The URI for my request looks like this:

`https://del.icio.us/html/jblanton/?&count=25

&rssbutton=no&bullet=&divclass=bit&aclass=bit_link`

After figuring out the syntax it was just a matter of coming up with a way to pull it off the del.icio.us server. I decided to use Perl and the following is all the code that was needed. [Note that this could be done in one line with something like curl: curl https://address -o file.txt]

#!/usr/bin/perl
use LWP::Simple;
$bits = get https://del.icio.us/html/user/your/args;
open(FILE, >/path/to/the/file/you/want/to/write/to);
print FILE $bits;
close(FILE);

You could obviously use PHP or JavaScript to yank this information down each time the page is loaded, but why hit the del.icio.us server every time someone requests a page from you? Instead, just create a cron job that runs the above script every 15 minutes or so and then include the returned file in pages that are requested by your users. I use PHP for the include:

<?php include('/path/to/file'); ?>

Finally, you’ll need to modify your CSS so that the text you’ve pulled down from del.icio.us gets styled inline with the rest of your site.

Like I said, there are a million different ways to bring your del.icio.us bookmarks into your site, but this seemed like the simplest to me. If I decide on a different method in the future, I’ll be sure to outline instructions for that method here.

You've successfully subscribed to POLYMATH.
Success! Your account is fully activated, you now have access to all content.