RSS is an exciting,
yet not quite new standard that lets you publish news from your page for other pages to syndicate.
FeedCreator.class.php provides an easy way to create RSS feeds from within PHP
using ease to use classes.
Features:
creates valid feeds according to RSS 0.91,
1.0 or 2.0
as well as PIE 0.1 (deprecated),
OPML 1.0,
Unix mbox,
ATOM 0.3,
or customizable HTML or Javascript format.
configurable feed caching
very well documented and easy to use
Feed image
includes almost all RSS 0.91 attributes
decide which version to create during runtime
easy to use and well documented class interface
intelligently truncates strings when needed
Example for building an RSS 1.0 feed:
<?
include("feedcreator.class.php");
$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = "PHP news";
$rss->description = "daily news from the PHP scripting world";
$rss->link = "http://www.dailyphp.net/news";
$rss->syndicationURL = "http://www.dailyphp.net/".$PHP_SELF;
$image = new FeedImage();
$image->title = "dailyphp.net logo";
$image->url = "http://www.dailyphp.net/images/logo.gif";
$image->link = "http://www.dailyphp.net";
$image->description = "Feed provided by dailyphp.net. Click to visit.";
$rss->image = $image;
// get your news items from somewhere, e.g. your database:
mysql_select_db($dbHost, $dbUser, $dbPass);
$res = mysql_query("SELECT * FROM news ORDER BY newsdate DESC");
while ($data = mysql_fetch_object($res)) {
$item = new FeedItem();
$item->title = $data->title;
$item->link = $data->url;
$item->description = $data->short;
$item->date = $data->newsdate;
$item->source = "http://www.dailyphp.net";
$item->author = "John Doe";
$rss->addItem($item);
}
$rss->saveFeed("RSS1.0", "news/feed.xml");
?>
Version history:
v1.7.2
10-11-04
changed license to LGPL
v1.7.1
fixed a syntax bug
fixed left over debug code
v1.7
07-18-04
added HTML and JavaScript feeds (configurable via CSS) (thanks to Pascal Van Hecke)
added HTML descriptions for all feed formats (thanks to Pascal Van Hecke)
added a switch to select an external stylesheet (thanks to Pascal Van Hecke)
changed default content-type to application/xml
added character encoding setting
fixed numerous smaller bugs (thanks to Sören Fuhrmann of golem.de)
improved changing ATOM versions handling (thanks to August Trometer)
improved the UniversalFeedCreator's useCached method (thanks to Sören Fuhrmann of golem.de)
added charset output in HTTP headers (thanks to Sören Fuhrmann of golem.de)
added Slashdot namespace to RSS 1.0 (thanks to Sören Fuhrmann of golem.de)
v1.6
05-10-04
added stylesheet to RSS 1.0 feeds
fixed generator comment (thanks Kevin L. Papendick and Tanguy Pruvot)
fixed RFC822 date bug (thanks Tanguy Pruvot)
added TimeZone customization for RFC8601 (thanks Tanguy Pruvot)
fixed Content-type could be empty (thanks Tanguy Pruvot)
fixed author/creator in RSS1.0 (thanks Tanguy Pruvot)
v1.6 beta
02-28-04
Added Atom 0.3 support (not all features, though)
Improved OPML 1.0 support (hopefully - added more elements)
Added support for arbitrary additional elements (use with caution and see documentation)
code beautification :-)
considered beta due to some internal changes
v1.5.1
27-01-04
minor bug fixes and improvements
v1.5
06-01-04
added OPML 1.0 support
added more documentation
v1.4
11-11-03
optional feed saving and caching
improved documentation
minor improvements
v1.3
10-02-03
renamed to FeedCreator, as it not only creates RSS anymore
added support for mbox
tentative support for echo/necho/atom/pie/??? (thanks to Scott Reynen)
v1.2
07-20-03
intelligent auto-truncating of RSS 0.91 attributes
don't create some attributes when they're not set
documentation improved
fixed a real and a possible bug with date conversions
code cleanup
v1.1
07-03-03
added images to feeds
now includes most RSS 0.91 attributes
added RSS 2.0 feeds
oops, forgot to include a necessary function ;-)
v1.0
06-24-03
first version
last changed on 10-11-04
Quick feedback
Feedback heard: New support board! by Kai Blankenhorn (11-17-04) Some of you seem to like the idea to have a forum here, so there it is! It is still quite empty, but I've just put links to it all over my site so everybody at leasts notices. Now all you have to do is post :-)
Feedback requested: Support board? by Kai Blankenhorn (10-11-04) Thinking of how to give better support for my scripts: Do you think a support board would be useful? I don't know if I can reach the critical mass of users - right now I have around 100 visits per day for the scripts. Tell me if you would use it!
Processed some email by Kai Blankenhorn (10-11-04) I've finally got the time to process some of the email I've got in the last few weeks. Sorry to anybody whom I couldn't answer! It's pretty hard for me to answer support requests in the little time I can spare.
Anyway, I've found some treasures among the emails :-) FeedCreator is used in the Mambo CMS, and will probably soon be used in TWiki. Snif has two new translations, and pseudocron will have a bugfix in a few days.
finally new releases by Kai Blankenhorn (10-11-04) At last I've managed to put up two new releases of my scripts, snif and FeedCreator. Especially FeedCreator has had much user input and definitely needed a freshup. New feed types are HTML and JavaScript feeds, which can be included in any web page right away. Snif has become more configurable with the new version. You may now create central configuration files to use the same settings for multiple installations of snif within one webspace. Colors can now be configured using external stylesheets. If you have made a new color set for snif, send it to me and I'll put it on my site!
disadvantages of having a job by Kai Blankenhorn (07-07-04) I've started working in a full-time job last week (at sd&m, to be exact, which appears to be a great company so far). Unfortunately this means that I'll have less time for improving my scripts. But I definitely will! Pending are Brazilian Portuguese, Spanish and Greek translations for snif, and some fixes for FeedCreator. I'll see what I can do to create the new releases ASAP.
I'm alway happy to receive your code changes, so if you've made some improvements to one of my scripts, send them to me so other users can profit from them as well!