Available in Ariadne > 2.7.3
ar\connect\rss
This module allows you to easily retrieve and parse RSS feeds.
Example:
<pinp>
$rss = ar('connect/rss')
->client( 'http://www.nytimes.com/services/xml/rss/nyt/GlobalHome.xml' );
echo '<ul>';
foreach ( $rss->items as $item ) {
echo '<li><a href="'.$item->link.'">'.$item->title.'</a></li>';
}
echo '</ul>';
methods
(object) |
client |
Returns a new RSS client object. |
(object) |
parse |
Returns a new RSS client object with the data from the given RSS XML. |
client
(object) ar('connect/rss')->client( $url = null, $httpClient = null )
(string) |
$url |
The url of the RSS feed to retrieve. |
(object) |
$httpClient |
The HTTP client instance to use. |
This method returns a new RSS client object. If no feed url is specified, you can later specify this through the get()
method. You can pass a HTTP client object to use as the second argument. This allows you to preset a client with specific headers or other non-default options.
RSS Client API
(object) |
get |
Retrieves a feed and parses it. |
(object) |
parse |
Parses the given RSS XML. |
get
(object) $rssClient->get( $url, $request = null, $options =
array() )
(string) |
$url |
The URL of the RSS feed. |
(array) |
$request |
Extra arguments for the feed. |
(array) |
$options |
Extra options for the HTTP client. |
Retrieves a RSS feed from the given URL. It parses the returned RSS feed using the parse()
method. If the RSS feed couldn't be retrieved it will return an ar_error
object, otherwise it will return the RSS client object.
parse
(object) $rssClient->parse( $xml )
(string) |
$xml |
The RSS XML to parse. |
Parses the given RSS XML and makes the data available in the client object as properties:
Channel properties:
(string) |
title |
Required. The title of the RSS Feed. |
|
link |
Required. The link to the website corresponding with this channel. |
(string) |
description |
Required. A description of this channel. |
(array) |
items |
A list of items in the RSS feed. |
(string) |
language |
The language the channel is written in |
(string) |
copyright |
Copyright notice for content in the channel. |
(string) |
managingEditor |
Email address for person responsible for editorial content. |
(string) |
webMaster |
Email address for person responsible for technical issues relating to channel. |
(string) |
pubDate |
The publication date for the content in the channel. |
(string) |
lastBuildDate |
The last time the content of the channel changed. |
(string) |
category |
Specifies one or more categories that the channel belongs to. |
(string) |
generator |
A string indicating the program used to generate the channel. |
(array) |
cloud |
Allows processes to register with a cloud to be notified of updates to the channel. |
(int) |
ttl |
A number of minutes that indicates how long a channel can be cached before refreshing from the source. |
(array) |
image |
Specifies a GIF, JPEG or PNG image that can be displayed with the channel. |
(object) |
rawXML |
The raw channel XML as ar_xmlNodes list. |
Item properties:
(string) |
title |
The title of the item. |
(string) |
link |
The URL of the item. |
(string) |
description |
The item synopsis. |
(string) |
author |
Email address of the author of the item. |
(string) |
category |
Includes the item in one or more categories. |
(string) |
comments |
URL of a page for comments relating to the item. |
(array) |
enclosure |
Describes a media object that is attached to the item. |
(string) |
guid |
A string that uniquely identifies the item. |
(string) |
pubDate |
Indicates when the item was published. |
(string) |
source |
The RSS channel that the item came from. |
(object) |
rawXML |
The raw item XML as an ar_xmlElement. |
Read more about the details of RSS 2.0.