Building a Generic RSS Class With PHP - Testing Our Class
(Page 5 of 6 )
Testing our class is easy. It should be separated into its own file, class.myRSS.php. You should use PHP to include this file and output the value from the GetRSS function. Once you’ve done this, any other Webmaster can grab and parse your RSS XML feed to display your headlines on their site, and you can also submit the link to your RSS file to RSS listings to drive an insane amount of traffic back to your site.
Here's a quick example. Save it as rss.php in your root directory on your web server, along with class.myRSS.php and modify it as you need to:
include("class.myRSS.php");
// Instantiate the myRSS class
$myRSS = new myRSS;
$myRSS->channelTitle = "My sample channel";
$myRSS->channelLink = "http://www.mysite.com";
$myRSS->channelDesc = "My sample RSS XML channel";
$myRSS->imageTitle = "My sample channel";
$myRSS->imageLink = "http://www.mysite.com/mylogo.gif";
$myRSS->imageURL = "http://www.mysite.com";
// Get the RSS data
$rssData = $myRSS->GetRSS("localhost", "admin", "password", "rssDB", "myArticles", "title", "summary", "articleId", "http://www.mysite.com/articles/{linkId}/");
// Output the generated RSS XML
header("Content-type: text/xml");
echo $rssData;Next: Conclusion >>
More MySQL Articles
More By Mitchell Harper