RSS Reader в PHP
How to show an RSS feed with a simple PHP function. File URL
- locally, as: rs.xml, or
- deleted as: https://www.iqlevsha.ru/rss.xml.
There is only one difference if the filename has the extension. "php," when it is generated by the CMS or other software, locally the file is treated as a text file by the server, and remotely treated as a script. It makes no difference whether the extension is. "xml."
The script is compatible with:
- RSS 2.0.
- RSS RDF or RSS 1.0.
In fact, the script extracts the title, link, and description tags and ignores the document structure format.
The advantage of using PHP to display an RSS feed is that it will be visible to search engines.
RSS 2.0 File Structure
An RSS stream consists of a feed and one or more items corresponding to articles. Everyone has a name, URL and description. Read more in the specification referenced below.
<rss version="2.0">
<channel>
<title> RSS</title>
<link>https://www.iqlevsha.ru/rss/</link>
<description>
Tools et documents pour RSS.
</description>
<item>
<title>Le lecteur RSS</title>
<link>https://www.iqlevsha.ru/rss/lecteur-rssphp</link>
<description>
Fonction pour afficher un flux RSS.
</description>
</item>
</channel>
</rss>
API functions
The interface consists of two functions:
RSS_Display()
To view a complete stream with a feed, headers, related articles, and their descriptions.
RSS_Links()
To view only a list of titles associated with items.
Source code
The source contains other internal functions:
RSS_Retrieve(url) // extraie le channel et appelle RSS_Channel.
RSS_Channel(channel) // extraie les données du channel et appelle RSS_Tags.
RSS_RetrieveLink(url) // appelle RSS_Tags pour chaque item d'un channel.
RSS_Tags(item) // extraie title, links, description pour un article.
See the rsslib.php script.
Show date
Version 2010 adds an argument to add date mapping.
RSS_Display(url, nombre, true, true);
If the last parameter is missing, the date is not displayed .
Show link on site or not
Version 2009 allows you to view the name and description of the site. This is the third RSS_Display parameter.
By default, it is not displayed. To show it, use this syntax:
RSS_Display(url, nombre, true);
Otherwise, call:
RSS_Display(url, nombre);
or:
RSS_Display(url);
the default number of articles is 15.
Demo
Demos are templates that can be learned and used on your own site, according to the terms of the Mozilla license. You can use the form to enter the URL of the stream. You can delete a form and replace it with the URL of a specific thread. The RSS feed can appear on the same or a different page.
- Displays the RSS feed on the same page.
- Show an RSS feed on another page.
- Show headers only.
- Show the stream directly on the page by enabling the PHP script.
This demonstration uses a style sheet file. - Demonstration of RSS feed caching.
Versions
The amendments take into account questions in French/English forums.
- August 10, 2010.
Add a caching demonstration. - May 4, 2010.
- Add a style sheet demonstration.
- The rss-getty .php demo shows how to show the feed as a web page parameter.
- An additional date is also displayed.
Loading
The archive contains a script and a demo.
- RSS Reader PHP (2010). Latest version.
Documentation
- Frequent questions about the RSS player.
- How to hide an RSS feed.
- Build RSS Feed. Textbook.
- Specifications 2.0. Harvard's translation of the standard into .fr.
- Use URL for RSS drive.
License: Mozilla 1.1. Screenplay by Denis Suro.
- RSS: Beginner's Aid.
- How to start with rsslib?
- Error reading RSS feed.
- Problem with RSS player.
- Error reading some threads.
- Setting the display.
- How do I find RSS feed dates?
- How do I verify an RSS feed?
RSS drive in PHP 4
Dev
webmaster