PHP function to display a feed in the Atom format
To complete the article "Displaying an RSS feed", this page explains how to display a feed in the Atom format.
The script is compatible with Atom 1.0, it could work with other versions.
The interface is comprised of two functions:
For displaying a complete feed with the feed, the titles linking to articles and the subTitle for the feed or summary for each article.
For displaying only the list of titles linking to articles.
The source is simpler than the RSS version because there is only one feed while RSS (RDF) allows for multiple channels. Internal functions are these:
Atom_Retrieve(url) // get the feed element and call Atom_Feed. Atom_Feed(channel) // extract data for the feed and call Atom_Tags for each item. Atom_RetrieveLink(url) // extract items for a fee and call Atom_Tags for each one. Atom_Tags(item) // extract title, link, summary for an article.View the atomlib.php script.
The archive holds the script and the demos.
- Atom Reader. The script requires PHP 5.
- Demos included in the archive:
- Displaying the Atom feed on the same page.
- Displaying only the titles, and links of the feed.
- Displaying directly the feed on a page, without to enter the URL.
- How to build
a universal feed reader. Tutorial, building a reader for any format.