Building a Monthly del.icio.us Bookmark Summary with PHP

Feb
01
2007

If you followed this site over the last couple of months, you might have noticed a few days where my del.icio.us bookmarks (hereafter: delicious) for the day appeared as a post. I removed the feature after a couple of days because it bugged me.

  1. I specifically avoid posts on this site that are little more than, "Dude, here's a cool site". Just not my thing. However, there are sites and resources I'd like to share from time to time. Just not every day, see #2.
  2. They were too often. I generally pace this site at about 3-5 articles a week or so. The daily bookmark posts were going to quickly drown out the other content and I didn't want the front page to be 80% bookmarks.
  3. I was using their tools to post them, which is an all or nothing affair. I couldn't just post the interesting bookmarks. There's nothing in there that I want to hide, but some of it just isn't worth sharing.

Then, yesterday, I caught someone in my feeds doing a "monthly bookmark summary" (can't find the link at the moment for who). That struck me as a much better balance. I could still share the useful resources without filling the site up with the crap. However, I'd have to write my own script to pull them together.

After fighting with what I think was a delicious site problem, where I got a "403 Forbidden" error on every request, even the manual ones, the final result wasn't very complicated at about 40 lines of code.

Basically, to do this, you need PHP and the CURL extension as well as your delicious username and password. The delicious api has a setting for getting the bookmarks for a given date. So, the script has a slot for the month and year at the top along with the username and password. Obviously, if you didn't want to have to edit this every time you use it, you could pass in the month and year on the URL, but I didn't bother as it makes a better tutorial if it's self-contained.

Anyway, the script then uses the month and year in combination with some of the date and time functions in PHP (including strtotime, which is the most magical function in PHP programming). It calculates how many days are in the month in question as well as making sure that we don't ask delicious for any dates in the future (in case you want to run this before the month is over).

Then, it loops through the month and grabs the bookmarks, printing each out on the page. If you wanted an easier cut/paste (as I'm likely to want myself), you could dump a 2nd copy of the content into a <textarea> tag as well.

At any rate, because trying to get code snippets to look right on this site is starting to drive me nuts, I again just made this a quick PDF of the code listing. Hopefully, tonight I'll actually get around to using it for a January summary. For now, I have to get to work and get Oracle to bend to my will.

Download the source as PDF

 

Comments on this post

Feedback is always welcome. Read some from other folks or leave your own below. Just keep things civil and remember that what you post lives on in public. Forever.

Thanks,
J

Leave Your Own Comment

By submitting a comment, you agree to license it under the terms of the Creative Commons Attribution license.

People who post comments get the added benefit of visiting the site without advertising.

© 2003-2009 J Wynia. All original content is licensed under the terms of the Creative Commons Attribution license unless otherwise noted. Content from other sources is licensed under its original terms.