function getPhotosInPhotoset($id) { $yaml_path = $_SERVER['DOCUMENT_ROOT'] . '/_content/photos/'; $flickr = new Flickr(self::api_key, self::api_secret); $parameters = array('photoset_id' => $id, 'extras' => 'description,url_o,url_l,url_m,url_s,geo,date_taken,tags,owner_name'); $response = $flickr->call('flickr.photosets.getPhotos', $parameters); foreach ($response['photoset']['photo'] as $photo) { //first of all check if we already have this image on home server... $slug = Slug::make($photo['id']); $slug = preg_replace('/[^a-z\\d]+/i', '-', $slug); $datetime = date('Y-m-d-Hi', strtotime($photo['datetaken'])); $file = $datetime . "-" . $slug . ".md"; $archive_file = preg_replace('"\\.md$"', '.gallery', $file); $collection_file = preg_replace('"\\.md$"', '.collection', $file); if (!File::exists($yaml_path . $file) && !File::exists($yaml_path . $archive_file) && !File::exists($yaml_path . $collection_file)) { $this->log->info('Trying to create a gallery without a pre-exiting photo `' . $photo['title'] . '`'); return false; } else { //archive this file, it slows down the site. if (File::exists($yaml_path . $file)) { rename($yaml_path . $file, $yaml_path . $archive_file); } if (File::exists($yaml_path . $collection_file)) { rename($yaml_path . $collection_file, $yaml_path . $archive_file); } //we're fine to start writing the array $arr_return[] = $this->makePhotoYAML($photo); } } return $arr_return; }
<?php $configFile = dirname(__FILE__) . '/config.php'; if (file_exists($configFile)) { include $configFile; } else { die("Please rename the config-sample.php file to config.php and add your Flickr API key and secret to it\n"); } spl_autoload_register(function ($className) { $className = str_replace('\\', DIRECTORY_SEPARATOR, $className); include dirname(__FILE__) . '/../src/' . $className . '.php'; }); use DPZ\Flickr; $flickr = new Flickr($flickrApiKey, $flickrApiSecret); $parameters = array('user_id' => '50317659@N00', 'per_page' => 100, 'extras' => 'url_sq,path_alias'); $response = $flickr->call('flickr.photos.search', $parameters); $photos = $response['photos']; ?> <!DOCTYPE html> <html> <head> <title>DPZFlickr Example</title> <link rel="stylesheet" href="example.css" /> </head> <body> <h1>Photos from dopiaza</h1> <ul id="photos"> <?php foreach ($photos['photo'] as $photo) { ?> <li>
spl_autoload_register(function ($className) { $className = str_replace('\\', DIRECTORY_SEPARATOR, $className); include dirname(__FILE__) . '/../src/' . $className . '.php'; }); use DPZ\Flickr; // Build the URL for the current page and use it for our callback $callback = sprintf('%s://%s:%d%s', @$_SERVER['HTTPS'] == "on" ? 'https' : 'http', $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['SCRIPT_NAME']); $flickr = new Flickr($flickrApiKey, $flickrApiSecret, $callback); if (!$flickr->authenticate('read')) { die("Hmm, something went wrong...\n"); } $userNsid = $flickr->getOauthData(Flickr::USER_NSID); $userName = $flickr->getOauthData(Flickr::USER_NAME); $userFullName = $flickr->getOauthData(Flickr::USER_FULL_NAME); $parameters = array('per_page' => 100, 'extras' => 'url_sq,path_alias'); $response = $flickr->call('flickr.stats.getPopularPhotos', $parameters); $ok = @$response['stat']; if ($ok == 'ok') { $photos = $response['photos']; } else { $err = @$response['err']; die("Error: " . @$err['msg']); } ?> <!DOCTYPE html> <html> <head> <title>DPZFlickr Auth Example</title> <link rel="stylesheet" href="example.css" /> </head> <body>