2010-12-24
Flickr API Corners: flickr.photos.getAllContexts
This is inspired by Matt Jones’ Hello Little Fella Flickr group. We wanted to do the scoring based on whether you’d added your photo to the group, but it turns out that Flickr doesn’t provide that information in the API very easily.
Actually, that’s not true: you can do one call per photo to gets every pool and set a photo is in. However, the name is arguably part of the reason so few people know about it. The call is flickr.photos.getAllContexts.
The best way to explain the name is to look at the sidebar on any Flickr photo page. Underneath the user’s info, you’ll see a block for their photostream, and often then identical blocks for every set or group that the photo is in. Each of these blocks is a “context”, and each has its own order for going back and forth.
The API call returns a very short data structure, which contains <set> elements (for the user’s set that the photo is part of) and <pool> elements (for, unsurprisingly, the group IDs of the pools the photo has been posted to). If you know the ID of a pool (say, 796605@N25, for Hello Little Fella!) then you can easily find out if the photo is a member.
(It turns out that the Toms were actually aware of this, but it wasn’t easy for them to add this to the noticings data gathering flow. Still, I think this is worth dragging from the drafts folder and publishing.)
In Flickr’s terminology, a group contains one or more users, zero or more discussions and has a pool containing zero or more photos. Only users are allowed to add photos to a pool, or to contribute to a discussion (except for invited photos).