Search code examples
phpflickr

phpFlickr API photos_getRecent extras/owner_name isn't doing anything


I'm trying to use the photos_getRecent function which, in the source file, is described as:

function photos_getRecent ($jump_to = NULL, $extras = NULL, $per_page = NULL, $page = NULL)

I'm trying to filter the results based on the owner, which (according to the documentation http://www.flickr.com/services/api/flickr.photos.getRecent.htm) is stored in the extras variable:

"A comma-delimited list of extra information to fetch for each returned record. Currently supported fields are: description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o"

So I've tried setting the extras variable to a whole lot of stuff:

photos_getRecent(NULL,"owner_name=john citizen",20,NULL);
photos_getRecent(NULL,"owner_name=john_citizen",20,NULL);
photos_getRecent(NULL,"owner_name:john citizen",20,NULL);
photos_getRecent(NULL,"owner_name:john_citizen",20,NULL);
photos_getRecent(NULL,"owner_name,john citizen",20,NULL);
photos_getRecent(NULL,"owner_name,john_citizen",20,NULL);
photos_getRecent(NULL,"owner_name=10000000@N00",20,NULL);
photos_getRecent(NULL,"owner_name:10000000@N00",20,NULL);
photos_getRecent(NULL,"owner_name,10000000@N00",20,NULL);

but none of them seem to do the trick. Every time it just gets a bunch of random photos with random owners.

Unfortunately the documentation isn't specific at all, and I can't find any examples online using this stuff.

How can I properly format the variable $extras to have it get me the photos only for that owner?


Solution

  • The extras parameter is used in the Flickr search to denote extra fields that you want returned by the API, not fields to search by.

    To get photos by a specific owner, you'll want to use photos_search function in the phpFlickr library and pass the argument user_id for your photo owner. The default sort order is date-posted-desc which should get what you are after. For example:

    photos_search (array('user_id' => '10000000@N00'));
    

    Check out Flickr's API doco for the search function for more details.