PHP script for reading RSS

PHP RSS Reader
Ever think about displaying news thumbnail on your blog / website ? The RSS technology and PHP script make this possible.
RSS (an abbreviation for Really Simple Syndication) is a family of Web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format. An RSS document (which is called a “feed”, “web feed”, or “channel”) includes full or summarized text, plus metadata such as publishing dates and authorship. Web feeds benefit publishers by letting them syndicate content automatically. They benefit readers who want to subscribe to timely updates from favored websites or to aggregate feeds from many sites into one place. RSS feeds can be read using software called an “RSS reader”, “feed reader”, or “aggregator”, which can be web-based, desktop-based, or mobile-device-based. A standardized XML file format allows the information to be published once and viewed by many different programs. The user subscribes to a feed by entering the feed’s URI (often referred to informally as a “URL” (uniform resource locater), although technically the two terms are not exactly synonymous) into the reader or by clicking an RSS icon in a browser that initiates the subscription process. The RSS reader checks the user’s subscribed feeds regularly for new work, downloads any updates that it finds, and provides a user interface to monitor and read the feeds.
Since RSS formats are specified using XML, a generic specification for the creation of data formats, we can use PHP DOM (available as PHP 5) to read and parse the xml tree data.
XML format in RSS 2.0 file
A feed is made of a channel, and one or more items correspondent to articles. Each element has a title, a URL and a description. More details in the specification linked below.
<rss version="2.0">
<channel>
<title>Developing webs</title>
<link>http://www.sandaldjepit.com/</link>
<description>
PHP Tutorial and tricks.
</description>
<item>
<title>PHP script for reading RSS</title>
<link>http://sandaldjepit.com/2009/04/09/php-script-for-reading-rssphp-script-for-reading-rss/</link>
<description>
PHP Script contain functions for displaying an RSS feed.
</description>
</item>
</channel>
</rss>
There is PHP RSS Reader library contain functions to parse RSS’s XML file. PHP RSS Reader contain 2 main function to parse RSS file :
RSS_Display()
For displaying a complete feed with the channel, the titles linking to articles and their descriptions.
RSS_Links()
For displaying only a list of titles that link to articles.
The internal functions are :
RSS_Retrieve(url)// extract the channel and call RSS_Channel. RSS_Channel(channel)// extract data for the channel and call RSS_Tags for each item. RSS_RetrieveLink(url)// extract items for a channel and call RSS_Tags for each one. RSS_Tags(item)// extract title, link, description for an article.
Demo :
Demos are templates you can study and use on you own site, according to the Mozilla licence. A form allows to enter the URL of the feed. You can remove the form and replace it by the URL of a feed. The RSS feed may be displayed on the same page or another one.
- Displaying an RSS feed on the same page.
- Displaying an RSS feed into another page.
- Displaying only the titles, on the same page.
- Displaying directly a feed on a page, without to enter the URL.
Download
The archive holds the script and the demos.
- RSS Reader at Scriptol.com. The script requires PHP 5.
Reference :
RSS Article on Wikipedia http://en.wikipedia.org/wiki/Rss
PHP RSS Reader on scriptol.com http://www.scriptol.com/rss/rss-reader.php
Related posts: