Ejemplo n.º 1
0
 */
require_once __DIR__ . '/../../vendor/autoload.php';
if (count($argv) < 2 || count($argv) > 3) {
    print 'Usage: php -f generate_explore http://path.com/feed [vote_count]';
    print "\n";
    exit;
} elseif (count($argv) === 3) {
    $votes = $argv[2];
} else {
    $votes = 100;
}
$url = $argv[1];
try {
    $config = new PicoFeed\Config\Config();
    $reader = new PicoFeed\Reader\Reader($config);
    $resource = $reader->discover($url);
    $location = $resource->getUrl();
    $content = $resource->getContent();
    $encoding = $resource->getEncoding();
    $parser = $reader->getParser($location, $content, $encoding);
    $feed = $parser->execute();
    $favicon = new PicoFeed\Reader\Favicon($config);
    $result = ["title" => $feed->getTitle(), "favicon" => $favicon->find($url), "url" => $feed->getSiteUrl(), "feed" => $feed->getFeedUrl(), "description" => $feed->getDescription(), "votes" => $votes];
    if ($feed->getLogo()) {
        $result["image"] = $feed->getLogo();
    }
    print json_encode($result, JSON_PRETTY_PRINT);
} catch (\Exception $ex) {
    print $ex->getMessage();
}
print "\n";
Ejemplo n.º 2
0
    // 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">