PHP Classes

How to Use a PHP RSS Feed Parser That Avoids Blocking From Content Delivery Network Services That Block Robots Using the Package RSS Fetch XML: Fetch and cache a RSS feed from a given URL

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-11-03 (Less than 1 hour ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
rssfetchxml 1.1MIT/X Consortium ...5XML, PHP 5, Web services
Description 

Author

This package can fetch and cache an RSS feed from a given URL.

It provides a class that can take a URL of an RSS feed and retrieves it using PHP's simplexml and cURL extensions, so it does not require PHP allow_url_fopen enabled to be set.

The class uses an HTTP user agent that is the same as the current user browser to avoid being blocked by content delivery network services such as CloudFlare that block robots.

The class can parse the RSS feed XML data and return a object with the RSS feed structure.

The RSS feed data can be stored in a local file in a given directory for a period of a given time length to avoid accessing the same RSS feed URL.

Innovation Award
PHP Programming Innovation award winner
July 2025
Winner
RSS feeds let Websites share content in a way if it is easy to process by other sites because they use a standard format based on XML.

Websites usually use automated scripts that act like robots that retrieve and parse RSS feeds from other sites.

The increasing number of robots that are accessing Websites lead to content delivery services to block aggressive robots.

This package provides an RSS feed retrieving class that is friendly with other Websites and can avoid blocks from content delivery services that block robots.

Manuel Lemos
Picture of Mike Jordan
  Performance   Level  
Name: Mike Jordan <contact>
Classes: 6 packages by
Country: United States United States
Age: 62
All time rank: 1460221 in United States United States
Week rank: 195 Up19 in United States United States Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Instructions

Please check this example script to learn how to retrieve, parse and cache RSS feeds of site contents.

Example

<?php include 'rssFetchXML.php'; ?>

<!doctype html>
<html lang="en">
    <head>
        <title>rssFetchXML Demo</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <link rel="stylesheet" href="" />
        <style>
        <!--
        html { font-size: 75%; font-family: verdana; }
        h1 { padding: 5px; text-align: center; }
        h3 { background: #eee; padding: 5px; }
        p { background: #eef7fb; padding: 5px; margin: 5px; }
        div { float: right; width: 30%; height: 400px;
              overflow-y: scroll; background: #aaa; padding: 10px; margin: 10px; }
        h4 { padding: 5px; text-align: center; }
        -->
        </style>
    </head>
    <body>
        <header>
        <!-- Begin header content -->
            <h1>rssFetchXML Demo</h1>
        <!-- End header content -->
        </header>
        <main>
        <!-- Begin main content -->
        <?php
            $new
= new rssFetchXML;
            echo
rss_feed( 'https://sports.yahoo.com/rss', $new );
            echo
rss_feed( 'https://www.stereogum.com/feed/', $new );
            echo
rss_feed( 'https://www.panthers.com/rss/news', $new );
            echo
rss_feed( 'https://www.tdpri.com/forums/-/index.rss', $new );
            echo
rss_feed( 'https://www.dailymail.co.uk/ushome/index.rss', $new );
            echo
rss_feed( 'https://stackoverflow.blog/feed/', $new );
        
?>
<!-- End main content -->
        </main>
        <footer>
        <!-- Begin footer content -->
            <h4>rssXmlFetch &copy 2025</h4>
        <!-- End footer content -->
        </footer>
    </body>
</html>

<?php

function rss_feed( $url, $new ) {
   
$new->rss_xml_cache = 'cache';
   
$new->rss_xml_expire = 3600;

   
$rss = @$new->rss_xml_fetch($url);
   
$output = '';

    if (
is_object($rss)) {
       
$output .= '<div><h3><a href="' . $rss->channel->link . '" target="_blank">'. $rss->channel->title . '</a></h3>';

        foreach (
$rss->channel->item as $item )
           
$output .= '<p><a href="'. $item->link .'" target="_blank" style="">' . $item->title . '</a></p>';

       
$output .= '</div>';
    } else {
       
$output .= '<div>RSS fetch failed - RSS url or feed may be invalid</div>';
    }

        return
$output;
    }


Details

rssFetchXML

App: rssFetchXML Version: 1.1 Author: MT Jordan <[email protected]> Copyright: 2025 License: MIT License

*

rssFetchXML: RSS feed aggregator

rssFetchXML fetchs RSS feeds using a simple PHP class

*

rssFetchXML Features:

* Extremely compact code that simplifies hooking into projects utilizing
  PHP's simplexml and cURL
* Does not require allow_url_fopen enabled
* Using simplexml with cURL sends "friendly" RSS requests that networks such
  as Cloudflare may treat as bots with other methods
* Display unlimited RSS feeds with a single class instance
* Auto creates cached XML files 
* Cache dir and cache expiration time set in script but can be overridden
  on the client side
* See rssFetchXML_demo.php for examples

rssFetchXML Requirements:

* PHP 5.6+
* Enabled libxml extension
* Enabled cURL extension

*


  Files folder image Files (4)  
File Role Description
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file rssFetchXML.php Class Class source
Accessible without login Plain text file rssFetchXML_demo.php Example Demo file

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 75%
Total:0
This week:0