You are here

function flickrapi_get_user_nsid in Flickr API 7

Same name and namespace in other branches
  1. 5 flickrapi.module \flickrapi_get_user_nsid()
  2. 6 flickrapi.module \flickrapi_get_user_nsid()
  3. 7.2 flickrapi.module \flickrapi_get_user_nsid()

Tries to match an 'identifier' onto a flickr nsid.

This function will first see whether $identifier is already a nsid (format check only, no api call). If it is not and the identifier has the format of an email, an api call will be made to check whether there is an nsid for that email. If this is not the case, the $identifier is treated as a username and an api call is made to find the nsid for that username.

If none of these succees, the result will be false

Parameters

Array $identifier: identifier to find an nsid for

Return value

String valid nsid or false if none can be found

1 call to flickrapi_get_user_nsid()
FlickrApiTestCase::testflickrapi_is_nsid in tests/flickrapi.test

File

./flickrapi.module, line 211
FlickAPI integration module.

Code

function flickrapi_get_user_nsid($identifier) {
  if (flickrapi_is_nsid($identifier)) {

    // Identifier is an NSID.
    return $identifier;
  }
  if ($f = flickrapi_phpFlickr()) {
    if (valid_email_address($identifier) && ($user = $f
      ->people_findByEmail($identifier))) {
      return $user['nsid'];
    }
    if ($user = $f
      ->people_findByUsername($identifier)) {
      return $user['nsid'];
    }
  }
  return FALSE;
}