You are here

public function FlickrFeedsParser::parse in Flickr 7

File

feeds/FlickrFeedsParser.inc, line 12
Flickr feeds parser class.

Class

FlickrFeedsParser
Class definition for Flickr Parser.

Code

public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  $flickr_feed = $fetcher_result
    ->getRaw();
  $result = new FeedsParserResult();
  $json = json_decode($flickr_feed);
  $items = array();
  foreach ($json->items as $entry) {
    $items[] = array(
      'title' => isset($entry->title) ? $entry->title : '',
      'link' => isset($entry->link) ? $entry->link : '',
      'media' => isset($entry->media->m) ? $entry->media->m : '',
      'date_taken' => isset($entry->date_taken) ? $entry->date_taken : '',
      'description' => isset($entry->description) ? $entry->description : '',
      'published' => isset($entry->published) ? $entry->published : '',
      'author' => isset($entry->author) ? $entry->author : '',
      'author_id' => isset($entry->author_id) ? $entry->author_id : '',
      'tags' => isset($entry->tags) ? $entry->tags : '',
    );
  }
  $result->items = $items;
  return $result;
}