You are here

function flickr_photos_search in Flickr 7

Same name and namespace in other branches
  1. 5 flickr.inc \flickr_photos_search()
  2. 6 flickr.api.inc \flickr_photos_search()

Return a list of photos matching some criteria.

Parameters

string $nsid: NSID of the user whose photoset tags will be returned.

string $page: Page of results to return.

Return value

array Response from the flickr method flickr.photos.search. (https://www.flickr.com/services/api/flickr.photos.search.html)

3 calls to flickr_photos_search()
flickr_album in ./flickr.inc
Render multiple photos as an album.
flickr_photos in ./flickr.module
Flickr photos (as shown on a user profile).
flickr_tags_photos in tags/flickr_tags.module
Returns a user's photos with given tags.

File

./flickr.api.inc, line 61
Flickr API functions.

Code

function flickr_photos_search($nsid, $page = 1, $other_args = array()) {

  // The user ID that gets returned from flickr_user_find_by_identifier('').
  $tags = isset($other_args['tags']) ? $other_args['tags'] : '';
  $nsid = $nsid == 'public' || $nsid == '39873962@N08' || empty($nsid) ? '' : $nsid;
  $other_args['group_id'] = isset($other_args['group_id']) ? $other_args['group_id'] : '';
  if ($nsid == '39873962@N08' || empty($nsid)) {
    $args = array(
      'user_id' => '',
      'group_id' => $other_args['group_id'],
      'tag_mode' => 'all',
      'license' => $other_args['license'],
      'page' => $page,
    );
  }
  else {
    $args = array(
      'user_id' => $nsid,
      'page' => $page,
    );

    // No license restrictions if a user ID is specified.
    $other_args['license'] = '';
  }

  // Set per_page to flickr module default if not specified in $other_args.
  if (!isset($other_args['per_page'])) {
    $args['per_page'] = variable_get('flickr_photos_per_page', 6);
  }
  $response = flickr_request('flickr.photos.search', array_merge($args, $other_args));
  if ($response) {
    return $response['photos'];
  }
  return FALSE;
}