Chris@0: # Feed Discovery from Web Pages
Chris@0:
Chris@0: Web pages often contain `` tags that refer to feeds with content relevant
Chris@0: to the particular page. `Zend\Feed\Reader\Reader` enables you to retrieve all
Chris@0: feeds referenced by a web page with one method call:
Chris@0:
Chris@0: ```php
Chris@0: $feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
Chris@0: ```
Chris@0:
Chris@0: > ## Finding feed links requires an HTTP client
Chris@0: >
Chris@0: > To find feed links, you will need to have an [HTTP client](zend.feed.http-clients)
Chris@0: > available.
Chris@0: >
Chris@0: > If you are not using zend-http, you will need to inject `Reader` with the HTTP
Chris@0: > client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
Chris@0:
Chris@0: Here the `findFeedLinks()` method returns a `Zend\Feed\Reader\FeedSet` object,
Chris@0: which is in turn a collection of other `Zend\Feed\Reader\FeedSet` objects, each
Chris@0: referenced by `` tags on the `news.html` web page.
Chris@0: `Zend\Feed\Reader\Reader` will throw a
Chris@0: `Zend\Feed\Reader\Exception\RuntimeException` upon failure, such as an HTTP
Chris@0: 404 response code or a malformed feed.
Chris@0:
Chris@0: You can examine all feed links located by iterating across the collection:
Chris@0:
Chris@0: ```php
Chris@0: $rssFeed = null;
Chris@0: $feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
Chris@0: foreach ($feedLinks as $link) {
Chris@0: if (stripos($link['type'], 'application/rss+xml') !== false) {
Chris@0: $rssFeed = $link['href'];
Chris@0: break;
Chris@0: }
Chris@0: ```
Chris@0:
Chris@0: Each `Zend\Feed\Reader\FeedSet` object will expose the `rel`, `href`, `type`,
Chris@0: and `title` properties of detected links for all RSS, Atom, or RDF feeds. You
Chris@0: can always select the first encountered link of each type by using a shortcut:
Chris@0: the first encountered link of a given type is assigned to a property named after
Chris@0: the feed type.
Chris@0:
Chris@0: ```php
Chris@0: $rssFeed = null;
Chris@0: $feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
Chris@0: $firstAtomFeed = $feedLinks->atom;
Chris@0: ```