topical media & game development

talk show tell print

server-webapi-code-04-feedSideCaching.php / php



  <?php
          header("Content-Type: text/xml");
          include("./feedcache.php");
          if (cacheIsRecent())
          {
            echo getCache();  
          }else
          {
            ob_start();
  ?><rss version="2.0"> 
    <channel> 
      <language>en</language> 
      <title>Easy Recipes</title>
      <description>Easy recipes for the computer hacker/culinary slacker.</description> 
      <link>example.preinheimer.com/feed1.php<image> 
        <title>Easy Recipes</title> 
        <link>example.preinheimer.com/feed1.php<url>example.preinheimer.com/feed1.png</image><?php
      include("./common_db.php");
      query = "SELECT * FROM 11_basic_feed";
      recipies = getAssoc(query);
      foreach(recipies AS item)
      {
        echo "<item>\n";
        echo "<title>{item['title']}</title>\n";
        echo "<link>{item['link']}</link>\n";
        echo "<description>{item['description']}</description>\n";
        echo "<author>{item['author']}</author>\n";
        echo "<category>{item['category']}</category>\n";
        echo "<pubdate>{item['pubdate']}</pubdate>\n";
        echo "</item>\n";
      }
      echo "</channel>\n</rss>";
    updateCache(ob_get_contents());
    ob_end_flush(); 
  }
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.