PHP code example of mehedimi / feed-reader

1. Go to this page and download the library: Download mehedimi/feed-reader 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/ */

    

mehedimi / feed-reader example snippets



    $feed = new \Mehedi\Feed();
    // Reading RSS Feed
    $rss = $feed->rss('http://your-url.com/rss')
                ->read();
   
    echo $rss->getTitle(); // Get the channel title

    // Access channel extra field
    echo $rss->channel()->extra;
    
    foreach ($rss->items() as $item) {
        echo $item->title; // Get the item title
        // Accessing attribute
        echo $item->title->attributes()->attributeName;
    }

    // Reading Atom Feed

    $atom = $feed->atom('http://your-url.com/atom')
                 ->read();
    
    echo $atom->getTitle(); // Title
    echo $atom->getUpdated()->format('d F, Y'); // Last Updated Date

    // Access channel extra field
    echo $atom->feed()->extra;

    foreach ($atom->entries() as $entry) {
        echo $entry->title; // Get the item title
        // Accessing attribute
        echo $entry->title->attributes()->attributeName;
    }



$feed = new \Mehedi\Feed();

$feed->rss('url')
     ->basicAuth('username', 'password')
     ->read();
// OR
$feed->atom('url')
     ->basicAuth('username', 'password')
     ->read();


    // Just use Feed Facade
    $rss = \Mehedi\Facades\Feed::rss('url')->read();