RSS Feed Generator for PHP - Documentation
This document was based on RSS 2.0 specification which can be found at
http://blogs.law.harvard.edu/tech/rss.
Classes
class rssGenerator_rss
Parameters:
Methods:
[ Top ]
string rss_version
The version of RSS that the document conforms to. Required, default - '2.0'.
Example:
$rss_feed->version = '2.0';
[ Top ] [ rssGenerator_rss ]
string rss_encoding
The XML encoding. Optional, not used by default.
Example:
$rss_feed->encoding = 'UTF-8';
[ Top ] [ rssGenerator_rss ]
string stylesheet
The stylesheet description. Optional, not used by default.
Example:
$rss_feed->stylesheet = '<?xml-stylesheet type="text/css" href="rss_style.css"?>';
$rss_feed->stylesheet = '<?xml-stylesheet type="text/xsl" href="rss_style.xsl"?>';
[ Top ] [ rssGenerator_rss ]
string cData(string str)
Static method. Returns the string in <![CDATA[ ... ]]> parentheses.
Example:
$rss_channel->description = rssGenerator_rss::cData('Here is a <a href="http://example.com/">link</a>.');
[ Top ] [ rssGenerator_rss ]
string createFeed(rssGenerator_channel channel)
Generates XML code based on applied channel data.
Example:
<?php
require_once 'rss_generator.inc.php';
$rss_channel = new rssGenerator_channel();
$rss_channel->title = 'My News';
$rss_channel->link = 'http://mysite.com/news.php';
$rss_channel->description = 'The latest news about web-development.';
$rss_channel->language = 'en-us';
$rss_channel->generator = 'PHP RSS Feed Generator';
$rss_channel->managingEditor = 'editor@mysite.com';
$rss_channel->webMaster = 'webmaster@mysite.com';
$item = new rssGenerator_item();
$item->title = 'New website launched';
$item->description = 'Today I finaly launch a new website.';
$item->link = 'http://newsite.com';
$item->pubDate = 'Tue, 07 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;
$item = new rssGenerator_item();
$item->title = 'Another website launched';
$item->description = 'Just another website launched.';
$item->link = 'http://anothersite.com';
$item->pubDate = 'Wen, 08 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;
$rss_feed = new rssGenerator_rss();
$rss_feed->version = '2.0';
header('Content-Type: text/xml');
echo $rss_feed->createFeed($rss_channel);
?>
[ Top ] [ rssGenerator_rss ]
class rssGenerator_channel
Parameters:
[ Top ]
string title
The name of the channel. It's how people refer to your service. If you have an
HTML website that contains the same information as your RSS file, the title of
your channel should be the same as the title of your website. Required.
Example:
$rss_channel->title = 'MySite.com News Headlines';
[ Top ] [ rssGenerator_channel ]
string link
The URL to the HTML website corresponding to the channel. Required.
Example:
$rss_channel->link = 'http://www.mysite.com/';
[ Top ] [ rssGenerator_channel ]
string description
Phrase or sentence describing the channel. Required.
Example:
$rss_channel->description = 'The latest news from MySite.com.';
[ Top ] [ rssGenerator_channel ]
string language
The language the channel is written in. This allows aggregators to group all
Italian language sites, for example, on a single page. A list of allowable values
for this element, as provided by Netscape, is
here.
You may also use
values
defined by the W3C. Optional.
Example:
$rss_channel->language = 'en-us';
[ Top ] [ rssGenerator_channel ]
string copyright
Copyright notice for content in the channel. Optional.
Example:
$rss_channel->copyright = 'Copyright 2006, Vagharsh Tozalakyan';
[ Top ] [ rssGenerator_channel ]
string managingEditor
Email address for person responsible for editorial content. Optional.
Example:
$rss_channel->managingEditor = 'editor@mysite.com';
[ Top ] [ rssGenerator_channel ]
string webMaster
Email address for person responsible for technical issues relating to channel.
Optional.
Example:
$rss_channel->webMaster = 'webmaster@mysite.com';
[ Top ] [ rssGenerator_channel ]
string pubDate
The publication date for the content in the channel. For example, the New York
Times publishes on a daily basis, the publication date flips once every 24 hours.
That's when the pubDate of the channel changes. All date-times in RSS conform to
the Date and Time Specification of
RFC 822, with the exception
that the year may be expressed with two characters or four characters
(four preferred). Optional.
Example:
$rss_channel->pubDate = date('r');
[ Top ] [ rssGenerator_channel ]
string lastBuildDate
The last time the content of the channel changed. Optional.
Example:
$rss_channel->lastBuildDate = 'Tue, 07 Mar 2006 08:00:00 GMT';
[ Top ] [ rssGenerator_channel ]
array categories
Specify categories that the channel belongs to. Each element is itself an array
of name and optional domain. Optional.
Example:
$rss_channel->categories[] = array('name'=>'Newspapers', 'domain'=>'');
$rss_channel->categories[] = array('name'=>'Journals', 'domain'=>'');
[ Top ] [ rssGenerator_channel ]
string generator
A string indicating the program used to generate the channel. Optional.
Example:
$rss_channel->generator = 'PHP RSS Feed Generator';
[ Top ] [ rssGenerator_channel ]
string docs
A URL that points to the documentation for the format used in the RSS file. It's
for people who might stumble across an RSS file on a Web server 25 years from now
and wonder what it is. Optional.
Example:
$rss_channel->docs = 'http://blogs.law.harvard.edu/tech/rss';
[ Top ] [ rssGenerator_channel ]
string ttl
Stands for time to live. It's a number of minutes that indicates how long a
channel can be cached before refreshing from the source. Optional.
Example:
$rss_channel->ttl = '60';
[ Top ] [ rssGenerator_channel ]
rssGenerator_image image
Specifies a GIF, JPEG or PNG image that can be displayed with the channel. See
also rssGenerator_image class. Optional.
Example:
$rss_image = new rssGenerator_image();
$rss_image->url = 'http://mysite.com/images/logo.png';
$rss_image->title = '';
$rss_image->link = '';
$rss_image->width = 88;
$rss_image->height = 31;
$rss_image->description = '';
...
$rss_channel->image = $rss_image;
[ Top ] [ rssGenerator_channel ]
rssGenerator_textInput textInput
Specifies a text input box that can be displayed with the channel. See also
rssGenerator_textInput class. Optional.
Example:
$rss_textInput = new rssGenerator_textInput();
$rss_textInput->title = 'Subscribe';
$rss_textInput->description = 'Enter your e-mail address, please';
$rss_textInput->name = 'email';
$rss_textInput->link = 'http://mysite.com/subscribe.php';
...
$rss_channel->textInput = $rss_textInput;
[ Top ] [ rssGenerator_channel ]
array skipHours
An array that contains up to 24 elements whose value is a number between 0 and 23,
representing a time in GMT, when aggregators, if they support the feature, may
not read the channel on hours listed in the skipHours array. The hour beginning
at midnight is hour zero. Optional.
Example:
$rss_channel->skipHours = array(0, 15, 22);
[ Top ] [ rssGenerator_channel ]
string skipDays
An array that contains up to seven elements whose value is Monday, Tuesday,
Wednesday, Thursday, Friday, Saturday or Sunday. Aggregators may not read the
channel during days listed in the skipDays array. Optional.
Example:
$rss_channel->skipDays = array('Monday', 'Friday');
[ Top ] [ rssGenerator_channel ]
string cloud_domain
The domain name or IP address of the cloud. Optional, but required if any of
cloud parameters defined.
Example:
$rss_channel->cloud_domain = 'rpc.sys.com';
[ Top ] [ rssGenerator_channel ]
string cloud_port
The TCP port that the cloud is running on. Optional, but required if any of
cloud parameters defined.
Example:
$rss_channel->cloud_port = '80';
[ Top ] [ rssGenerator_channel ]
string cloud_path
The location of its responder. Optional, but required if any of
cloud parameters defined.
Example:
$rss_channel->cloud_path = '/RPC2';
[ Top ] [ rssGenerator_channel ]
string cloud_registerProcedure
The name of the procedure to call to request notification. Optional, but required
if any of cloud parameters defined.
Example:
$rss_channel->cloud_registerProcedure = 'myCloud.rssPleaseNotify';
[ Top ] [ rssGenerator_channel ]
string cloud_protocol
Xml-rpc, soap or http-post (case-sensitive), indicating which protocol is to be
used. Optional, but required if any of cloud parameters defined.
Example:
$rss_channel->cloud_protocol = 'xml-rpc';
[ Top ] [ rssGenerator_channel ]
array items
An array of item objects. See also rssGenerator_item class.
Example:
...
$rss_item = new rssGenerator_item();
$rss_item->title = 'New website launched';
$rss_item->description = 'Today I finaly launch a new website.';
$rss_item->link = 'http://newsite.com';
$rss_item->pubDate = 'Tue, 07 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;
[ Top ] [ rssGenerator_channel ]
string extraXML
Any additional XML code that can be included to channel element. Optional.
[ Top ] [ rssGenerator_channel ]
class rssGenerator_image
Parameters:
[ Top ]
string url
The URL of a GIF, JPEG or PNG image that represents the channel. Required.
[ Top ] [ rssGenerator_image ]
string title
Describes the image, it's used in the ALT attribute of the HTML <img> tag when
the channel is rendered in HTML. Required.
[ Top ] [ rssGenerator_image ]
string link
The URL of the site, when the channel is rendered, the image is a link to the
site. (Note, in practice the image <title> and <link> should have the same
value as the channel's <title> and <link>. Required.
[ Top ] [ rssGenerator_image ]
string width
Number, indicating the width of the image in pixels. Maximum value for width is
144, default value is 88. Optional.
[ Top ] [ rssGenerator_image ]
string height
Number, indicating the height of the image in pixels. Maximum value for height
is 400, default value is 31. Optional.
[ Top ] [ rssGenerator_image ]
string description
The text that is included in the TITLE attribute of the link formed around the
image in the HTML rendering. Optional.
[ Top ] [ rssGenerator_image ]
class rssGenerator_textInput
Parameters:
[ Top ]
string title
The label of the Submit button in the text input area. Required.
[ Top ] [ rssGenerator_textInput ]
string description
Explains the text input area. Required.
[ Top ] [ rssGenerator_textInput ]
string name
The name of the text object in the text input area. Required.
[ Top ] [ rssGenerator_textInput ]
string link
The URL of the CGI script that processes text input requests. Required.
[ Top ] [ rssGenerator_textInput ]
class rssGenerator_item
[ Top ]
string title
The title of the item. Optional.
Example:
$rss_item->title = 'Venice Film Festival Tries to Quit Sinking';
[ Top ] [ rssGenerator_item ]
string link
The URL of the item. Optional.
Example:
$rss_item->link = 'http://nytimes.com/2004/12/07FEST.html';
[ Top ] [ rssGenerator_item ]
string description
The item synopsis. Optional.
Example:
$rss_item->description = 'Some of the most heated chatter at the Venice
Film Festival this week was about the way that the arrival of the stars at the
Palazzo del Cinema was being staged.';
[ Top ] [ rssGenerator_item ]
string author
Email address of the author of the item. Optional.
[ Top ] [ rssGenerator_item ]
string pubDate
Indicates when the item was published. Optional.
[ Top ] [ rssGenerator_item ]
string comments
URL of a page for comments relating to the item. Optional.
[ Top ] [ rssGenerator_item ]
string guid
A string that uniquely identifies the item. Optional.
[ Top ] [ rssGenerator_item ]
string guid_isPermaLink
isPermaLink is optional, its default value is true. If its value is false, the
guid may not be assumed to be a url, or a url to anything in particular.
[ Top ] [ rssGenerator_item ]
string source
The RSS channel that the item came from. Optional.
Example:
$rss_item->source = 'Tomalak\'s Realm';
$rss_item->source_url = 'http://www.tomalak.org/links2.xml';
[ Top ] [ rssGenerator_item ]
string source_url
The URL that links to the XMLization of the source. Optional, but required if
source defined.
[ Top ] [ rssGenerator_item ]
string enclosure_url
Describes a media object that is attached to the item. It says where the enclosure
is located. Optional, but required if any of enclosure parameters defined.
[ Top ] [ rssGenerator_item ]
string enclosure_length
Describes a media object that is attached to the item. It says how big it is in bytes.
Optional, but required if any of enclosure parameters defined.
[ Top ] [ rssGenerator_item ]
string enclosure_type
Describes a media object that is attached to the item. It says what its type is -
a standard MIME type. Optional, but required if any of enclosure parameters defined.
[ Top ] [ rssGenerator_item ]
string categories
Includes the item in one or more categories. See also the
categories property of
rssGenerator_channel class.
[ Top ] [ rssGenerator_item ]