RSSBuilder
[ class tree: RSSBuilder ] [ index: RSSBuilder ] [ all elements ]

Source for file rss_sample_script.php

Documentation is available at rss_sample_script.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. //+----------------------------------------------------------------------+
  4. //| WAMP (XP-SP1/1.3.29/4.1.1/5.0.0RC1) |
  5. //+----------------------------------------------------------------------+
  6. //| Copyright (c) 1992-2003 Michael Wimmer |
  7. //+----------------------------------------------------------------------+
  8. //| I don't have the time to read through all the licences to find out |
  9. //| what the exactly say. But it's simple. It's free for non commercial |
  10. //| projects, but as soon as you make money with it, i want my share :-) |
  11. //+----------------------------------------------------------------------+
  12. //| Authors: Michael Wimmer <flaimo@gmx.net> |
  13. //+----------------------------------------------------------------------+
  14. //
  15. // $Id: rss_sample_script.php,v 1.1 2005/03/26 07:18:56 weizhuo Exp $
  16.  
  17.  
  18.  
  19. /**
  20. * @package RSSBuilder
  21. * @category FLP
  22. * @filesource
  23. */
  24. error_reporting(E_ALL);
  25. ob_start();
  26. include_once 'RSSBuilder.php';
  27.  
  28. /* create the object - remember, not all attibutes are supported by every rss version. just hand over an empty string if you don't need a specific attribute */
  29. $encoding =(string) 'UTF-8';
  30. $about = (string) 'http://flaimo.com/';
  31. $title = (string) 'flaimo.com fake news';
  32. $description = (string) 'non existing news about my homepage';
  33. $image_link = (string) 'http://flaimo.com/small_logo.png';
  34. $category = (string) 'PHP Development'; // (only rss 2.0)
  35. $cache = (string) 60; // in minutes (only rss 2.0)
  36. $rssfile = new RSSBuilder($encoding, $about, $title, $description, $image_link, $category, $cache);
  37.  
  38. /* if you want you can add additional Dublic Core data to the basic rss file (if rss version supports it) */
  39. $publisher = (string) 'Flaimo'; // person, an organization, or a service
  40. $creator = (string) 'Flaimo'; // person, an organization, or a service
  41. $date = (string) time();
  42. $language = (string) 'en';
  43. $rights = (string) 'Copyright ? 2003 Flaimo.com';
  44. $coverage = (string) ''; // spatial location , temporal period or jurisdiction
  45. $contributor = (string) 'Flaimo'; // person, an organization, or a service
  46. $rssfile->addDCdata($publisher, $creator, $date, $language, $rights, $coverage, $contributor);
  47.  
  48. /* if you want you can add additional Syndication data to the basic rss file (if rss version supports it) */
  49. $period = (string) 'daily'; // hourly / daily / weekly / ...
  50. $frequency = (int) 1; // every X hours/days/...
  51. $base = (string) time()-10000;
  52. $rssfile->addSYdata($period, $frequency, $base);
  53.  
  54. /* data for a single RSS item */
  55. $about = $link = 'http://flaimo.com/sometext.php?somevariable=somevalue';
  56. $title = (string) 'A fake news headline';
  57. $description = (string) 'some abstract text about the fake news';
  58. $subject = (string) 'technology'; // optional DC value
  59. $date = (string) time(); // optional DC value
  60. $author = (string) 'Flaimo'; // author of item
  61. $comments = (string) 'http://flaimo.com/sometext.php?somevariable=somevalue&amp;comments=1'; // url to comment page rss 2.0 value
  62. $image = (string) 'http://flaimo.com/small_logo2.png'; // optional mod_im value for dispaying a different pic for every item
  63. $rssfile->addRSSItem($about, $title, $link, $description, $subject, $date, $author, $comments, $image);
  64. $rssfile->addRSSItem($about, $title, $link, $description, $subject, $date, $author, $comments, $image);
  65. // add as much items as you want ...
  66.  
  67. $version = '2.0'; // 0.91 / 1.0 / 2.0
  68. $rssfile->outputRSS($version);
  69. /*
  70. // if you don't want to directly output the content, but instead work with the string (for example write it to a cache file) use
  71. $foo = $rssfile->getRSSOutput($version);
  72. */
  73.  
  74. /*
  75. // saves the xml file to the given path and returns the path + filename as a string
  76. $path = '';
  77. echo $rssfile->saveRSS($version, $path = '');
  78. */
  79.  
  80. ob_end_flush();
  81. ?>

© 2004-2005 PRADO Software Group. All Rights Reserved.