flickr = new phpFlickr($flickrApiKey, $flickrApiSecret, false); $this->feedUrl = $feedUrl; $this->rss = fetch_rss($this->feedUrl); } function getTitle() { return $this->rss->channel['title']; } function getDescription() { return $this->rss->channel['description']; } function getLink() { return $this->rss->channel['link']; } function getItems() { $items = array(); foreach ($this->rss->items as $item) { $newsItem = new NewsItem($item); $photos = $this->findImages($newsItem->getKeywords()); $photoCount = 0; foreach ($photos as $photo) { $squarePhoto = 'http://static.flickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' .$photo['secret'] . '_s.jpg'; $photoPage = 'http://www.flickr.com/photos/' . $photo['owner'] . '/' . $photo['id'] . '/'; $newsItem->addPhoto($squarePhoto, $photoPage); if (++$photoCount >= $this->maxPhotos) { break; } } array_push($items, $newsItem); if (count($items) >= $this->maxStories) { break; } } return $items; } function findImages($keywords) { $args = array( 'tags' => join($keywords, ','), 'tag_mode' => 'any', 'sort' => 'relevance', 'page' => 1, 'per_page' => $this->maxPhotos, ); $photos = $this->flickr->photos_search($args); if ($this->flickr->getErrorCode()) { // Display error message and return an empty set of photos echo $this->flickr->getErrorMsg() . " whilst searching for photos"; return array(); } return $photos['photo']; } } ?>