[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/rssbuilder/ -> rss_sample_script.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4: */
   3  //+----------------------------------------------------------------------+
   4  //| WAMP (XP-SP3/2.2/5.2/5.1.0)                                          |
   5  //+----------------------------------------------------------------------+
   6  //| Copyright(c) 2001-2008 Michael Wimmer                                |
   7  //+----------------------------------------------------------------------+
   8  //| Licence: GNU General Public License v3                               |
   9  //+----------------------------------------------------------------------+
  10  //| Authors: Michael Wimmer <flaimo@gmail.com>                           |
  11  //+----------------------------------------------------------------------+
  12  //
  13  // $Id$
  14  
  15  /**
  16  * @package RSS
  17  * @category flaimo-php
  18  * @filesource
  19  */
  20  error_reporting(E_ALL);
  21  ob_start();
  22  include_once  'class.RSSBuilder.inc.php';
  23  
  24  /* 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 */
  25  $encoding =(string) 'UTF-8';
  26  $about = (string) 'http://flaimo.com/';
  27  $title = (string) 'flaimo.com fake news';
  28  $description = (string) 'non existing news about my homepage';
  29  $image_link = (string) 'http://flaimo.com/small_logo.png';
  30  $category = (string) 'PHP Development'; // (only rss 2.0)
  31  $cache = (string) 60; // in minutes (only rss 2.0)
  32  $rssfile = new RSSBuilder($encoding, $about, $title, $description, $image_link, $category, $cache);
  33  
  34  /* if you want you can add additional Dublic Core data to the basic rss file (if rss version supports it) */
  35  $publisher = (string) 'Flaimo'; // person, an organization, or a service
  36  $creator = (string) 'Flaimo'; // person, an organization, or a service
  37  $date = (string) time();
  38  $language = (string) 'en';
  39  $rights = (string) 'Copyright © 2008 Flaimo.com';
  40  $coverage = (string) ''; // spatial location , temporal period or jurisdiction
  41  $contributor = (string) 'Flaimo'; // person, an organization, or a service
  42  $rssfile->addDCdata($publisher,    $creator, $date, $language,    $rights, $coverage, $contributor);
  43  
  44  /* if you want you can add additional Syndication data to the basic rss file (if rss version supports it) */
  45  $period = (string) 'daily'; // hourly / daily / weekly / ...
  46  $frequency = (int) 1; // every X hours/days/...
  47  $base = (string) time()-10000;
  48  $rssfile->addSYdata($period, $frequency, $base);
  49  
  50  /* data for a single RSS item */
  51  $about = $link = 'http://flaimo.com/sometext.php?somevariable=somevalue';
  52  $title = (string) 'A fake news headline';
  53  $description = (string) 'some abstract <b>text</b> about the fake news';
  54  $subject = (string) 'technology'; // optional DC value
  55  $date = (string) time(); // optional DC value
  56  $author = (string) 'Flaimo'; // author of item
  57  $comments = (string) 'http://flaimo.com/sometext.php?somevariable=somevalue&amp;comments=1'; // url to comment page rss 2.0 value
  58  $image = (string) 'http://flaimo.com/small_logo2.png'; // optional mod_im value for dispaying a different pic for every item
  59  $rssfile->addRSSItem($about, $title, $link, $description, $subject, $date,    $author, $comments, $image);
  60  $rssfile->addRSSItem($about, $title, $link, $description, $subject, $date,    $author, $comments, $image);
  61  // add as much items as you want ...
  62  
  63  $version = '2.0'; // 0.91 / 1.0 / 2.0
  64  $rssfile->outputRSS($version);
  65  /*
  66  // 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
  67  $foo = $rssfile->getRSSOutput($version);
  68  */
  69  
  70  /*
  71  // saves the xml file to the given path and returns the path + filename as a string
  72  $path = '';
  73  echo $rssfile->saveRSS($version, $path = '');
  74  */
  75  
  76  ob_end_flush();
  77  ?>


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7