You are here

function flickrapi_phpFlickr in Flickr API 7

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

Returns the phpFlickr object.

If we need to change anything, such as making the cache configuration, then it'll all be done here.

Return value

phpFlickr The phpFlickr object

3 calls to flickrapi_phpFlickr()
FlickrApiTestCase::testPhpFlickrClass in tests/flickrapi.test
flickrapi_flush_caches in ./flickrapi.module
Implements hook_flush_caches().
flickrapi_get_user_nsid in ./flickrapi.module
Tries to match an 'identifier' onto a flickr nsid.

File

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

Code

function flickrapi_phpFlickr($clear_cache = FALSE) {
  $flickr = FALSE;
  $library = libraries_load('phpFlickr');

  // Check if the library is loaded properly.
  if (!empty($library) && $library['loaded'] !== FALSE) {
    $api_key = variable_get('flickrapi_api_key', '');
    $api_secret = variable_get('flickrapi_api_secret', '');
    $cache = variable_get('flickrapi_cache', '');
    $cache_dir = variable_get('flickrapi_cache_path', '');
    if (empty($api_key) || empty($api_secret)) {
      drupal_set_message(t("Flickr API key not set"), 'error');
      if (user_access('configure flickr api')) {
        drupal_set_message(t('Please !configure', array(
          '!configure' => l(t('configure the Flickr API settings'), 'admin/config/media/flickrapi'),
        )));
      }
    }
    $flickr = new phpFlickr($api_key, $api_secret);

    // Override the default post function to enable OAuth.
    $flickr
      ->setCustomPost('_flickrapi_post');

    // Enable caching.
    if ($cache == TRUE) {
      if ($clear_cache == TRUE) {
        $flickr
          ->enableCache('fs', $cache_dir, 0);
      }
      else {
        $flickr
          ->enableCache('fs', $cache_dir);
      }
    }
  }
  return $flickr;
}