Browsing all articles tagged with RSS
27
1

[PHP]一个非常好用的RSS生成类

Author Jessica     Category PHP, 收集整理     Tags ,

先看例子:

  1. //include("feedcreator.class.php");   
  2.  
  3. $rss = new UniversalFeedCreator();   
  4. $rss->useCached();   
  5. $rss->title = "PHP news";   
  6. $rss->description = "daily news from the PHP scripting world";   
  7.  
  8. //optional  
  9. //$rss->descriptionTruncSize = 500;  
  10. //$rss->descriptionHtmlSyndicated = true;  
  11. //$rss->xslStyleSheet = "http://feedster.com/rss20.xsl";  
  12.  
  13. $rss->link = "http://www.dailyphp.net/news";   
  14. $rss->feedURL = "http://www.dailyphp.net/".$PHP_SELF;   
  15.  
  16. $image = new FeedImage();   
  17. $image->title = "dailyphp.net logo";   
  18. $image->url = "http://www.dailyphp.net/images/logo.gif";   
  19. $image->link = "http://www.dailyphp.net";   
  20. $image->description = "Feed provided by dailyphp.net. Click to visit.";   
  21.  
  22. //optional  
  23. $image->descriptionTruncSize = 500;  
  24. $image->descriptionHtmlSyndicated = true;  
  25.  
  26. $rss->image = $image;   
  27.  
  28. // get your news items from somewhere, e.g. your database:   
  29. //mysql_select_db($dbHost, $dbUser, $dbPass);   
  30. //$res = mysql_query("SELECT * FROM news ORDER BY newsdate DESC");   
  31. //while ($data = mysql_fetch_object($res)) {   
  32.     $item = new FeedItem();   
  33.     $item->title = "This is an the test title of an item";   
  34.     $item->link = "http://localhost/item/";   
  35.     $item->description = "<b>description in </b><br/>HTML";   
  36.       
  37.     //optional  
  38.     //item->descriptionTruncSize = 500;  
  39.     $item->descriptionHtmlSyndicated = true;  
  40.       
  41.     $item->date = time();   
  42.     $item->source = "http://www.dailyphp.net";   
  43.     $item->author = "John Doe";   
  44.        
  45.     $rss->addItem($item);   
  46. //}   
  47.  
  48. // valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1,
  49. // MBOX, OPML, ATOM0.3, HTML, JS  
  50. echo $rss->saveFeed("RSS0.91""feed.xml");   

read more

分类目录

最近文章

近期评论

文章归档

标签

.net AJAX button Comet CSS Discuz! DIV+CSS Flash Form Google HTML编辑器 IE8 Java JavaScript jQuery JSP md5 MySQLReback OAuth Oracle PHP php-fpm PNG Punny SkiyoTabs tab TagCloud Vista Web2.0 Windows7 上传 加密 图标 本站原创 模板 模板引擎 源码 登录 短网址 石家庄 算法 编译 面向对象 魔术方法

链接表