✨ Finishes FlickrCollector
This commit is contained in:
parent
050788aabb
commit
fa43eeb60d
@ -17,27 +17,18 @@ class FlickrCollector extends Collector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function getRandomImage()
|
public function getRandomImage()
|
||||||
{
|
{
|
||||||
if (!$this->getConfig()->has('collector.flickr.key')) {
|
return $this->getRandomImages(1);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $number
|
* @param int $number
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function getRandomImages(int $number)
|
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']);
|
$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));
|
file_put_contents($this->getPoolDirectory() . '/' . basename(parse_url($img_url, PHP_URL_PATH)), file_get_contents($img_url));
|
||||||
}
|
}
|
||||||
var_dump($photos);
|
|
||||||
|
return $number;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user