<?
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");
?>
类的下载地址http://www.bitfolge.de/rsscreator-en.html
用php实现动态生成rss文件
最新推荐文章于 2021-04-04 01:47:39 发布
本文介绍了一个使用PHP创建RSS新闻订阅源的示例脚本,该脚本从数据库中获取最新新闻并将其转换为RSS1.0格式。通过简单的代码实现,可以轻松地将网站的内容以RSS形式提供给用户。
1678

被折叠的 条评论
为什么被折叠?



