SimplePie::get_author PHP Method

get_author() public method

Get an author for the feed
Since: 1.1
public get_author ( integer $key ) : SimplePie_Author | null
$key integer The author that you want to return. Remember that arrays begin with 0, not 1
return SimplePie_Author | null
    public function get_author($key = 0)
    {
        $authors = $this->get_authors();
        if (isset($authors[$key])) {
            return $authors[$key];
        } else {
            return null;
        }
    }

Usage Example

Ejemplo n.º 1
0
 function rss_to_activity_streams($data)
 {
     //
     $feed = new SimplePie();
     $feed->set_raw_data($data);
     //
     unset($data);
     //
     $feed->set_stupidly_fast(true);
     $feed->init();
     $feed->handle_content_type();
     //
     $id = md5($url);
     $title = 'submit';
     $link = 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
     $activityStream = new ActivityStreamsDoc($id, $title, $link);
     //
     foreach ($feed->get_items() as $item) {
         $author = $item->get_author();
         if (!$author) {
             $author = $feed->get_author();
         }
         //
         $activityStream->entry($item->get_id(), date("r", $item->get_date()), $author ? $author->get_name() : null, $author ? $author->get_link() : null, $item->get_title(), $item->get_permalink(), $item->get_description());
     }
     return $activityStream;
 }
All Usage Examples Of SimplePie::get_author