I like stuff I can pick up and do something useful with in an hour or two.
Perhaps my attention span is too short, but if I have to read a 300 page spec
before I get to Hello World, then it's not for me. Or you would at least have
to pay me a lot of money to suffer through it. I think people refer to this
as "immediacy". For me I think it is mostly lazyness. If I can't figure it
out in an hour, it's broken as far as I am concerned.
Flickr's REST API is not broken. You can read all about it at
http://flickr.com/services/api.
There are links there to various wrappers for the API, but I ended up writing
my own. I have a bad habit of doing that. This entry will focus on my
PHP wrapper for the Flickr API. It is based on Cal's version and is compatible
with it, but it expands on it and puts some PHP 5.1 features to good use. You can
see it here:
http://lerdorf.com/php/flickr_api.phps
Before you get started, in case you want to follow along, go get yourself an API
key at
http://flickr.com/services/api/key.gne
You will need two pieces of information to fully use the API. An API key and an API secret.
And if you are going to do anything that requires authentication, you need to set a
callback url as well. More on that later. To get your secret after applying for and
getting your API key, go to
http://www.flickr.com/services/api/registered_keys.gne
and click on "Edit Configuration".
Many functions in the API do not require authentication. Getting a list of someone's
public photos, for example, is something anybody can do by just browsing Flickr, or by
just going to this URL:
http://flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id=56053642@N00&api_key=3aba8184848f9263b80795c95529bcd1
Guess what, you just sent a REST Web Services query.
Or, slightly cooler. A list of tags related to the tag you provide based on Flickr's
clustering code.
http://flickr.com/services/rest/?method=flickr.tags.getRelated&tag=monkey&api_key=3aba8184848f9263b80795c95529bcd1