forked from blallo/rss-bridge
[FlickrExploreBridge] code simplification
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
29b4f954c2
commit
e139372255
1 changed files with 12 additions and 4 deletions
|
@ -3,11 +3,12 @@ class FlickrExploreBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public $maintainer = "sebsauvage";
|
public $maintainer = "sebsauvage";
|
||||||
public $name = "Flickr Explore";
|
public $name = "Flickr Explore";
|
||||||
public $uri = "https://www.flickr.com/explore";
|
public $uri = "https://www.flickr.com/";
|
||||||
public $description = "Returns the latest interesting images from Flickr";
|
public $description = "Returns the latest interesting images from Flickr";
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$html = $this->getSimpleHTMLDOM('https://www.flickr.com/explore') or $this->returnServerError('Could not request Flickr.');
|
$html = $this->getSimpleHTMLDOM($this->uri.'explore')
|
||||||
|
or $this->returnServerError('Could not request Flickr.');
|
||||||
|
|
||||||
foreach($html->find('.photo-list-photo-view') as $element) {
|
foreach($html->find('.photo-list-photo-view') as $element) {
|
||||||
// Get the styles
|
// Get the styles
|
||||||
|
@ -21,10 +22,17 @@ class FlickrExploreBridge extends BridgeAbstract{
|
||||||
$imageID = reset($imageURIs);
|
$imageID = reset($imageURIs);
|
||||||
|
|
||||||
// Get the image JSON via Flickr API
|
// Get the image JSON via Flickr API
|
||||||
$imageJSON = json_decode($this->getContents('https://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=103b574d49bd51f0e18bfe907da44a0f&photo_id='.$imageID.'&format=json&nojsoncallback=1')) or $this->returnServerError('Could not request Flickr.'); // FIXME: Request time too long...
|
$imageJSON = json_decode($this->getContents(
|
||||||
|
'https://api.flickr.com/services/rest/?'
|
||||||
|
.'method=flickr.photos.getInfo&'
|
||||||
|
.'api_key=103b574d49bd51f0e18bfe907da44a0f&'
|
||||||
|
.'photo_id='.$imageID.'&'
|
||||||
|
.'format=json&'
|
||||||
|
.'nojsoncallback=1'
|
||||||
|
)) or $this->returnServerError('Could not request Flickr.'); // FIXME: Request time too long...
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = 'https://flickr.com/photo.gne?id='.$imageID;
|
$item['uri'] = $this->uri.'photo.gne?id='.$imageID;
|
||||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $imageURI . '" /></a>'; // FIXME: Filter javascript ?
|
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $imageURI . '" /></a>'; // FIXME: Filter javascript ?
|
||||||
$item['title'] = $imageJSON->photo->title->_content;
|
$item['title'] = $imageJSON->photo->title->_content;
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
|
Loading…
Reference in a new issue