Exemplo n.º 1
0
    // echo "not a valid feed.";
    // die;
    // }
}
if (isset($_POST['widget_title'])) {
    $widget_title = trim($_POST['widget_title']);
}
if (isset($_POST['max_count'])) {
    $max_count = (int) $_POST['max_count'];
}
// Dropdowns are here if you need them.
// $dropdowns = new HTMLDropDown;
// use PicoFeed\Reader\Reader;
try {
    $reader = new PicoFeed\Reader\Reader();
    $resource = $reader->download($requested_feed);
    $parser = $reader->getParser($resource->getUrl(), $resource->getContent(), $resource->getEncoding());
    $feed_output = $parser->execute();
    // echo $feed;
} catch (Exception $e) {
    // echo "Something went wrong with the feed parser.";
}
?>

<?php 
if ($feed_output) {
    ?>
<div id="rss_widget_<?php 
    echo $widget_title;
    ?>
" class="news_feed">
Exemplo n.º 2
0
<?php

include 'vendor/autoload.php';
$reader = new \PicoFeed\Reader\Reader();
// Return a resource
$resource = $reader->download('http://rss.cnn.com/rss/cnn_topstories.rss');
// Return the right parser instance according to the feed format
$parser = $reader->getParser($resource->getUrl(), $resource->getContent(), $resource->getEncoding());
// Return a Feed object
$feed = $parser->execute();
$items = [];
foreach ($feed->items as $item) {
    $items[] = ['title' => $item->title, 'content' => strip_tags($item->content)];
}
exit(json_encode($items));