All pastes #228150 Raw Edit

Untitled

public text v1 · immutable
#228150 ·published 2006-10-29 22:02 UTC
rendered paste body
/*** GENERAL USAGE *********************************************************

include("feedcreator.class.php"); 

$rss = new UniversalFeedCreator(); 
$rss->useCached(); // use cached version if age<1 hour
$rss->title = "PHP news"; 
$rss->description = "daily news from the PHP scripting world"; 

//optional
$rss->descriptionTruncSize = 500;
$rss->descriptionHtmlSyndicated = true;

$rss->link = "http://www.dailyphp.net/news"; 
$rss->syndicationURL = "http://www.dailyphp.net/".$_SERVER["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."; 

//optional
$image->descriptionTruncSize = 500;
$image->descriptionHtmlSyndicated = true;

$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; 
    
    //optional
    item->descriptionTruncSize = 500;
    item->descriptionHtmlSyndicated = true;

    $item->date = $data->newsdate; 
    $item->source = "http://www.dailyphp.net"; 
    $item->author = "John Doe"; 
     
    $rss->addItem($item); 
} 

// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated),
// MBOX, OPML, ATOM, ATOM0.3, HTML, JS
echo $rss->saveFeed("RSS1.0", "news/feed.xml");