This afternoon, I was browsing through some photosets on Flickr, but the photos weren’t loading quickly. I thought to myself, why don’t I download them now and go through them later?
, but I couldn’t find a link to download a photoset.
I remembered that Flickr has an API, so I can write something myself to do it. It shouldn’t take long, maybe an hour, max. From their services page, I saw Ruby implementations. Even better, I thought, I’ll use that.
I started with flickr.rb, but immediately I hit my first setback.
It offered me a gems file. Flipping through my Pickaxe book, I see that RubyGems is the preferred way for installing Ruby modules. Sounds good, but Ubuntu doesn’t come with RubyGems, probably because it “clashes” with apt. After 10 minutes of looking around, I gave up on using Gems and downloaded the source directly.
I went back to my book to make sure I was including the library correctly and hit another setback. Flickr.rb requires xmlsimple, something akin to Perl’s XML::Simple module. I searched Ubuntu’s repos, but they don’t have it. I downloaded the tarball, built and installed it. That took another 10 minutes.
Let’s start cooking. But before that, I needed to get an API key to use the service. Ten minutes later, I got the magic key.
I got back into emacs and started reading the included samples. It looks pretty easy. I wrote something simple to test it:
f = Flickr.new
user = f.users('some user')
user.photos.each do |photo|
puts photo.url
end
It was slow and the URL is wrong, but I got something back. I wrote more code for going filtering through the photos from a user’s photoset. I ran it again, but I got nothing. I added some more lines for debugging and saw that it wasn’t returning any of the photos at all. In fact, the binding to flickr.photosets.getPhotos is actually marked as incomplete. Sigh. I tried to see if I can implement it myself. I tried to switch to the other Ruby implementation but the docs are even thinner. I took a brief look at the Python ones and they didn’t seem so hot either.
However, the API Explorer did work and the URL requests really are quite simple. So I decided to write my own implementation in Squeak, because I know Smalltalk better than I do Python or Ruby. I defined a class and started writing methods. I noticed I need to authenticate before I can make any calls. I followed the instructions and began to write a method to handle it.
Except I couldn’t find a method for doing MD5 sums. I asked on the IRC channel, they (basically) told me to file a bug.
By now, I was pretty pissed off. What was supposed to take 30 mins ended up taking an afternoon, and I still didn’t have anything usable. I really didn’t care much about the photos at this point.
Lately, I have been going back to the SOAP and WS-* specs and re-reading them. The last time I read WS-Addressing was before it got accepted into the W3c. Of course, SOAP is complicated and the discussions on EndpointReferences vs. URIs go on endlessly, but I just can’t help but think that grabbing a WSDL of a service and pumping it through ASP.NET Web Services (or better yet, Indigo) is easier than what I had (not) achieved this afternoon in trying to use the Flickr API.
Someone told me there’s a Flickr.NET. I’ll try it when I feel less pissed off about this whole thing. Heck, it might even work.