Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The Unofficial Ubuntu Starter Guide
Prev Home Next

Q: How to parse RSS into PHP for Apache HTTP Server?

  1. Read General Notes
  2. Read How to install Apache HTTP Server for HTTP (Web) Server service?
  3. Read How to install PHP for Apache HTTP Server?
  4. e.g. Assumed that RSS is DistroWatch.com - News
  5. wget -c https://frankandjacq.com/ubuntuguide/magpierss-0.71.1.tar.gz
    sudo mkdir /var/www/feeds
    sudo tar zxvf magpierss-0.71.1.tar.gz -C /var/www/feeds/
    sudo mv /var/www/feeds/magpierss-0.71.1/* /var/www/feeds/
    sudo rm -fr /var/www/feeds/magpierss-0.71.1/
    sudo chown -R www-data:root /var/www/feeds/
    sudo gedit /var/www/feeds/index.php
  6. Insert the following lines into the new file
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="https://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    
    <head>
    
    <title>DistroWatch.com - News</title>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    
    <style type="text/css">
    /*<![CDATA[*/
    /* 
    DEFAULT TAG STYLES
    */
    
    body {
      background: #ffffff;
      margin-left: 20px;
      font-family: bitstream vera sans,sans-serif;
      font-size: 9pt;
    }
    
    h1 {
      font-family: luxi sans,sans-serif;
      font-size: 15pt;
    }
    
    /*]]>*/
    </style>
    
    </head>
    
    <body>
    
    <?php
    
    require_once 'rss_fetch.inc';
    error_reporting(E_ERROR);
    
    $url = 'https://distrowatch.com/news/dw.xml';
    $rss = fetch_rss($url);
    
    if ($rss) {
    
      echo "<h1>";
      echo "<a href=$url>", $rss->channel[title], "</a><br/>";
      echo "</h1>";
    
      foreach ($rss->items as $item ) {
        $url = $item[link];
        $title = $item[title];
        $description = $item[description];
        echo "<li>";
        echo "<b>Topic:</b> <a href=$url><b><u>$title</u></b></a><br/><br/>";
        echo "$description<br/><br/>";
        echo "</li>";
      }
    
    }
    else {
      echo "<a href=$url>", $url, "</a> - Server Down!<br/>";
    }
    
    ?>
    
    </body>
    
    </html>
  7. Save the edited file (sample)
  8. https://localhost/feeds/index.php


FTP Server


The Unofficial Ubuntu Starter Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire