How To Discover RSS Feeds for a given URL How To Discover RSS Feeds for a given URL php php

How To Discover RSS Feeds for a given URL


Found something that I wanted:

Google's AJAX Feed API has a load feed and lookup feed function (Docs here).

a) Load feed provides the feed (and feed status) in JSON

b) Lookup feed provides the RSS feed for a given URL

Theres also a find feed function that searches for RSS feeds based on a keyword.

Planning to use this with JQuery's $.getJSON


The Zend Feed class of the Zend-framework can automatically parse a webpage and list the available feeds.

Example:

$feedArray = Zend_Feed::findFeeds('http://www.example.com/news.html');


This link will allow you to validate the link against the RSS/Atom specifications using the W3C specs, but does require you to manually enter the url.

There are a number of ways to do this programmatically, depending on your choice of language - in PHP, parsing the file as valid XML is a good way to start, then compare it to the relevant DTD.

For b), if the link itself isn't a feed, you can parse it and look for a specified feed in the <head> section of the page, searching for a link whose type is "application/rss+xml", e.g:

<link rel="alternate" title="RSS Feed"     href="http://www.example.com/rss-feed.xml" type="application/rss+xml" />

This type of link is the one used by most browsers to "auto-discover" feeds (causing the RSS icon to appear in your address bar)