| 
 Posted by Toby A Inkster on 02/13/07 14:11 
laredotornado@zipmail.com wrote: 
 
> I'm using PHP 4.4.4 with Apache 2.2.  I'm looking for recommendations 
> on free code I can use to generate RSS feeds. 
 
Here's the class I use for my current project. 
http://svn.sourceforge.net/viewvc/*checkout*/demiblog/trunk/blog/includes/Feed.class?revision=73&content-type=text%2Fplain 
 
It's uses PHP 5, but it should be reasonably simple to backport to PHP 4. 
 
Basic technique is: 
 
<?php 
	require_once 'Feed.class'; 
	$type = 'rss'; 
 
	$feed = Feed::factory($type); 
	$feed->title     = 'Example'; 
	$feed->url       = 'http://example.com/'; 
	$feed->summary   = '<p>Here is <b>my</b> site. It is nice.</p>'; 
	$feed->langguage = 'en_GB'; 
	$feed->add_item('Article 1', 
			'http://example.com/articles/1', 
			'<p>Article 1 is lovely.</p>'); 
	$feed->add_item('Article 2', 
			'http://example.com/articles/2', 
			'<p>Article 2 is even <b>better!</b>.</p>'); 
	$out = $feed->output(); 
 
	header("Content-Type: text/xml"); 
	print $out; 
?> 
 
It supports: 
 
	- RSS 0.91 
	- RSS 1.0 (RDF) 
	- RSS 2.0 (with or without HTML descriptions) 
	- Atom 1.0 (with or without HTML descriptions) 
	- HTML/hCalendar 
	- iCalendar 
	- JSON 
	- PHP serialize() 
	- Text (CSV) 
 
as output formats. It is reasonably easy to add support for other formats. 
 
--  
Toby A Inkster BSc (Hons) ARCS 
Contact Me ~ http://tobyinkster.co.uk/contact 
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux 
 
* = I'm getting there!
 
[Back to original message] 
 |