From fa43eeb60de703ba91e9cd4c613329cdf1a97717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 24 Feb 2021 17:46:11 +0100 Subject: [PATCH] :sparkles: Finishes FlickrCollector --- src/Collector/FlickrCollector.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Collector/FlickrCollector.php b/src/Collector/FlickrCollector.php index 54cb1b7..866fd63 100644 --- a/src/Collector/FlickrCollector.php +++ b/src/Collector/FlickrCollector.php @@ -17,27 +17,18 @@ class FlickrCollector extends Collector /** * @return int + * @throws \Exception */ public function getRandomImage() { - if (!$this->getConfig()->has('collector.flickr.key')) { - throw new \Exception('Flickr API key not found.'); - } - $flickr_client = new PhpFlickr( - $this->getConfig()->get('collector.flickr.key'), - $this->getConfig()->get('collector.flickr.secret') - ); - - $word_to_search = $this->getConfig()->get('collector.keywords.keywords', $this->generateRandomWord()); - - $photos = $flickr_client->photos()->search($word_to_search); - var_dump($photos); + return $this->getRandomImages(1); } /** * @param int $number * * @return int + * @throws \Exception */ public function getRandomImages(int $number) { @@ -63,6 +54,7 @@ class FlickrCollector extends Collector $img_url = sprintf('https://live.staticflickr.com/%s/%s_%s_b.jpg', $photo['server'], $photo['id'], $photo['secret']); file_put_contents($this->getPoolDirectory() . '/' . basename(parse_url($img_url, PHP_URL_PATH)), file_get_contents($img_url)); } - var_dump($photos); + + return $number; } -} \ No newline at end of file +}