anterior  
índice  
siguiente  
Updated 2012-10-02 - Version ZF 2.0.3

Retrieving Feeds from Web Pages

Web pages often contain <link> tags that refer to feeds with content relevant to the particular page. Zend\Feed\Reader\Reader enables you to retrieve all feeds referenced by a web page with one simple method call:

1
$feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');

Here the findFeedLinks() method returns a Zend\Feed\Reader\FeedSet object, that is in turn, a collection of other Zend\Feed\Reader\FeedSet objects, that are referenced by <link> tags on the news.html web page. Zend\Feed\Reader\Reader will throw a Zend\Feed\Reader\Exception\RuntimeException upon failure, such as an HTTP 404 response code or a malformed feed.

You can examine all feed links located by iterating across the collection:

1
2
3
4
5
6
7
$rssFeed = null;
$feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
foreach ($feedLinks as $link) {
    if (stripos($link['type'], 'application/rss+xml') !== false) {
        $rssFeed = $link['href'];
        break;
}

Each Zend\Feed\Reader\FeedSet object will expose the rel, href, type and title properties of detected links for all RSS, Atom or RDF feeds. You can always select the first encountered link of each type by using a shortcut:

1
2
3
$rssFeed = null;
$feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
$firstAtomFeed = $feedLinks->atom;
|

Tema anterior

Importing Feeds

Próximo tema

Consuming an RSS Feed

Esta página

Nota: Es necesario estar conectado a tu cuenta GitHub para contribuir a la documentación.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Retrieving Feeds from Web Pages on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.