PHP code example of dansup / rss-php

1. Go to this page and download the library: Download dansup/rss-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dansup / rss-php example snippets


$rss = Feed::loadRss($url);

echo 'Title: ', $rss->title;
echo 'Description: ', $rss->description;
echo 'Link: ', $rss->link;

foreach ($rss->item as $item) {
	echo 'Title: ', $item->title;
	echo 'Link: ', $item->link;
	echo 'Timestamp: ', $item->timestamp;
	echo 'Description ', $item->description;
	echo 'HTML encoded content: ', $item->{'content:encoded'};
}

$atom = Feed::loadAtom($url);

Feed::$client = new GuzzleHttp\Client(['headers' => ['User-Agent' => 'FeedPHP/1.0']]);

$atom = Feed::loadAtom($url, ['auth' => ['peter', 'secret']);

//  Simple volatile memory cache example check docs for more options 
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Kevinrob\GuzzleCache\CacheMiddleware;

// Create default HandlerStack
$stack = HandlerStack::create();

// Add this middleware to the top with `push`
$stack->push(new CacheMiddleware(), 'cache');

// Initialize the client with the handler option
Feed::$client = new Client(['handler' => $stack]);

php composer.phar