This site is rarely updated. benbrophy.com is more up-to-date. - Ben
REST APIs and Basic Knowledge
I'm adding a feature in Linkwalla that let's automatically add links to your del.icio.us account when you add a link to Linkwalla. I'm doing this using the del.icio.us api.
Figuring out the API was simple, and writing a function that would add the link was simple. The hard part was figuring out the first sentence line from the API description:
Everything in /api requires HTTP-Auth.
This is a problem I often run into as an wannabe programmer. I can figure out how some fairly fancy stuff works, but there are these little pieces of assumed knowledge that take for ever. I mean every body know how to make HTTP-Auth work, right? I spent hours googling, reading and rereading function descriptions of PHP.net, reading up on HTTP headers, and on and on. I found a great guide to using the del.icio.us API and thought my problem was solved until I read their explanation of HTTP-Auth:
del.icio.us is a login-based system, and uses HTTP-Auth for authentication.
That's it! Finally late last night I was searching through PHP books on O'Reilly's Safari service (free access to Safari is perk of working at MIT) and I found the answer in the book Upgrading to PHP 5. All I had to do was format the Delicious URL in a funny way:
http://username:password@del.icio.us/api/posts/add
Voila. I had it working in 30 seconds. So now I know. It took many hours of wasted time, but I'm a better nerd for it.
By the way, I've tried working with a SOAP API before, and REST is a piece of cake in comparison. I think it's definitely the way to go for Sakai services, if only because we have a goal of letting fuzzy-headed self-taught web developers like myself link their scripts into Sakai, and asking them to figure out SOAP puts big barrier in the way.
Tags: linkwalla rest del.icio.us oreilly