feed-io 4.3 : feed discovery

In version 4.3, feed-io now gets the ability to discover feeds included in the head section of a HTML page. For instance, browse to https://php.net and take a look at the page’s sources. You’ll see something like this in the head section :

  <title>PHP: Hypertext Preprocessor</title>

 <link rel="shortcut icon" href="https://php.net/favicon.ico">
 <link rel="search" type="application/opensearchdescription+xml" href="http://php.net/phpnetimprovedsearch.src" title="Add PHP.net search">
 <link rel="alternate" type="application/atom+xml" href="https://php.net/releases/feed.php" title="PHP Release feed">
 <link rel="alternate" type="application/atom+xml" href="https://php.net/feed.atom" title="PHP: Hypertext Preprocessor">

The interesting parts of it are the two <link rel="alternate" type="application/atom+xml" /> tags.

feed-io now gives you the ability to discover them with a few lines of code :

$feedIo = \FeedIo\Factory::create()->getFeedIo();
$feeds = $feedIo->discover($url);

foreach( $feeds as $feed ) {
    echo "discovered feed : {$feed}";
}

And there’s more. You can also get them using its command-line interface :

./vendor/bin/feedio discover http://php.net

Which outputs :

Discovering feeds from http://php.net
found : http://php.net/releases/feed.php
found : http://php.net/feed.atom

That means you can now get all available feeds from a website before consuming them.

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy