PHP code example of popphp / pop-feed

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

    

popphp / pop-feed example snippets


use Pop\Feed\Writer;

$headers = [
    'published' => date('Y-m-d H:i:s'),
    'author'    => 'Test Author'
];

$items = [
    [
        'title'       => 'Some Item #1',
        'link'        => 'http://www.popphp.org/',
        'description' => 'This is the description of item #1',
        'published'   => date('Y-m-d H:i:s')
    ],
    [
        'title'       => 'Some Item #2',
        'link'        => 'http://popcorn.popphp.org/',
        'description' => 'This is the description of item #2',
        'published'   => date('Y-m-d H:i:s')
    ]
];

$feed = new Writer($headers, $items);
$feed->render();

$feed = new Writer($headers, $items);
$feed->setAtom();
$feed->render();

use Pop\Feed\Reader;
use Pop\Feed\Format\Rss;

$feed = new Reader(new Rss('http://www.domain.com/rss'));

foreach ($feed->items as $item) {
    print_r($item);
}

use Pop\Feed\Reader;
use Pop\Feed\Format\Atom;

$feed = new Reader(new Atom('http://www.domain.com/feed'));

foreach ($feed->entries as $entry) {
    print_r($entry);
}