Beispiel #1
0
 /**
  * 运行
  */
 function run()
 {
     $rss = \Feed::loadRss($this->rssUrl);
     $data = ['title' => $rss->title, 'description' => $rss->description, 'link' => $rss->link, 'items' => $rss->item, 'articles' => $this->parseItems($rss->item)];
     $this->dataObject = (object) $data;
     return $this;
 }
Beispiel #2
0
 public function getFeed($options)
 {
     if (empty($options['sa_vim_username'])) {
         return array('error' => 4, 'message' => 'Error fetching Vimeo feed: <span class="social-feed-error">No user found.</span>');
     }
     $since_time = empty($options['sa_since_time']) ? 1 : $options['sa_since_time'];
     try {
         $rss = Feed::loadRss('http://vimeo.com/' . $options['sa_vim_username'] . '/videos/rss');
     } catch (FeedException $e) {
         return array('error' => 5, 'message' => 'Error fetching Vimeo feed: <span class="social-feed-error">' . $e->getMessage() . '</span>');
     }
     if (count($rss->item) == 0) {
         return array('error' => 1, 'message' => 'No items found in feed.');
     }
     $data = array();
     $date_added = time();
     $item_timestamps = array();
     foreach ($rss->item as $item) {
         // $item_timestamp = (int)$item->timestamp;
         $item_timestamp = strtotime((string) $item->pubDate);
         if ($item_timestamp > $since_time) {
             $p = array();
             $p['id'] = (string) $item->guid;
             $p['message'] = (string) $item->title;
             $p['description'] = (string) $item->description;
             $link = (string) $item->link;
             $p['link'] = $link;
             $namespaces = $item->getNameSpaces(true);
             $dc = $item->children($namespaces['dc']);
             $p['author'] = (string) $dc->creator;
             $p['date_added'] = $date_added;
             $p['date_created'] = strtotime((string) $item->pubDate);
             $video_id = substr($link, strrpos($link, '/') + 1);
             $p['video_id'] = $video_id;
             $vimeo_data = file_get_contents('http://vimeo.com/api/v2/video/' . $video_id . '.json');
             $vimeo_data = json_decode($vimeo_data);
             $vimeo_thumb = $vimeo_data[0]->thumbnail_large;
             $p['picture'] = $vimeo_thumb;
             $item_timestamps[] = $item_timestamp;
             array_push($data, $p);
         }
     }
     if (count($data) > 0) {
         $res = array('data' => $data, 'since_time' => max($item_timestamps));
         return $res;
     } else {
         return array('error' => 3, 'message' => 'No new Vimeo items found.');
     }
 }
 /**
  *  
  * @param   $url the url of the feed
  * @param   $config the array containing the configuration parameters: "limit", "timezone", "dateformat", "encoding"
  */
 public function __construct($url, $config = [])
 {
     //load xml from the Feed Class
     $rss = \Feed::loadRss($url);
     $dom = new \DOMDocument();
     $dom->loadHTML($rss->item->description);
     $this->manageConf($config);
     date_default_timezone_set($this->config['timezone']);
     $count = 0;
     foreach ($rss->item as $item) {
         $this->push($this->parseDescription($item));
         if ($this->config['limit'] && ++$count == $this->config['limit']) {
             break;
         }
     }
 }
Beispiel #4
0
 public function getFeed($options)
 {
     if (empty($options['sa_rss_url'])) {
         return array('error' => 4, 'message' => 'Error fetching RSS feed: <span class="social-feed-error">No URL provided.</span>');
     }
     $since_time = empty($options['sa_since_time']) ? 1 : $options['sa_since_time'];
     try {
         $rss = Feed::loadRss($options['sa_rss_url']);
     } catch (FeedException $e) {
         return array('error' => 5, 'message' => 'Error fetching RSS feed: <span class="social-feed-error">' . $e->getMessage() . '</span>');
     }
     if (count($rss->item) == 0) {
         return array('error' => 1, 'message' => 'No items found in feed.');
     }
     $data = array();
     $date_added = time();
     $item_timestamps = array();
     foreach ($rss->item as $item) {
         // $item_timestamp = (int)$item->timestamp;
         $item_timestamp = strtotime((string) $item->pubDate);
         if ($item_timestamp > $since_time) {
             $p = array();
             $p['id'] = (string) $item->guid;
             $p['message'] = (string) $item->title;
             $p['description'] = (string) $item->description;
             $link = (string) $item->link;
             $p['link'] = $link;
             $author = (string) $item->author;
             if (empty($author)) {
                 $namespaces = $item->getNameSpaces(true);
                 $dc = $item->children($namespaces['dc']);
                 $p['author'] = (string) $dc->creator;
             }
             $p['date_added'] = $date_added;
             $p['date_created'] = strtotime((string) $item->pubDate);
             $item_timestamps[] = $item_timestamp;
             array_push($data, $p);
         }
     }
     if (count($data) > 0) {
         $res = array('data' => $data, 'since_time' => max($item_timestamps));
         return $res;
     } else {
         return array('error' => 3, 'message' => 'No new RSS items found.');
     }
 }
Beispiel #5
0
 public function getFeed($options)
 {
     if (empty($options['sa_yt_username'])) {
         return array('error' => 4, 'message' => 'Error fetching YouTube feed: <span class="social-feed-error">No user found.</span>');
     }
     $since_time = empty($options['sa_since_time']) ? 1 : $options['sa_since_time'];
     $rss = Feed::loadRss('http://youtube.com/rss/user/' . $options['sa_yt_username']);
     if (count($rss->item) == 0) {
         return array('error' => 6, 'message' => 'Error fetching YouTube feed: <span class="social-feed-error">No items found or user does not exist.</span>');
     }
     $data = array();
     $date_added = time();
     $item_timestamps = array();
     foreach ($rss->item as $item) {
         // $item_timestamp = (int)$item->timestamp;
         $item_timestamp = strtotime((string) $item->pubDate);
         if ($item_timestamp > $since_time) {
             $p = array();
             $p['id'] = (string) $item->guid;
             $p['message'] = (string) $item->title;
             $p['description'] = (string) $item->description;
             $link = (string) $item->link;
             $p['link'] = $link;
             $p['author'] = (string) $item->author;
             $p['date_added'] = $date_added;
             $p['date_created'] = strtotime((string) $item->pubDate);
             $video_id = substr($link, strrpos($link, 'watch?v=') + 8);
             $video_id = substr($video_id, 0, strpos($video_id, '&'));
             $p['video_id'] = $video_id;
             $p['picture'] = 'http://img.youtube.com/vi/' . $video_id . '/0.jpg';
             $item_timestamps[] = $item_timestamp;
             array_push($data, $p);
         }
     }
     if (count($data) > 0) {
         $res = array('data' => $data, 'since_time' => max($item_timestamps));
         return $res;
     } else {
         return array('error' => 3, 'message' => 'No new YouTube items found.');
     }
 }
 protected function readFeed($url)
 {
     // Read feed
     $rss = \Feed::loadRss($url);
     $out = "";
     $count = 0;
     // Add feed information to the output
     $out .= '<h2>' . $rss->title . '</h2>';
     $out .= '<p>' . $rss->description;
     $out .= '<br><a href="' . $rss->link . '">Länk</a></p>';
     // Add feed items to the output (limited to three items)
     foreach ($rss->item as $item) {
         if ($count++ == 3) {
             return $out;
         }
         $out .= '<h3>' . $item->title . '</h3>';
         $out .= '<p>' . $item->description;
         $out .= '<br><a href="' . $item->link . '">Länk</a></p>';
     }
     return $out;
     // In case of fewer than 3 elements
 }
Beispiel #7
0
<?php

header('Content-Type: text/html; charset=utf-8');
if (!ini_get('date.timezone')) {
    date_default_timezone_set('Europe/Prague');
}
require_once 'src/Feed.php';
$rss = Feed::loadRss('http://phpfashion.com/feed/rss');
?>

<h1><?php 
echo htmlSpecialChars($rss->title);
?>
</h1>

<p><i><?php 
echo htmlSpecialChars($rss->description);
?>
</i></p>

<?php 
foreach ($rss->item as $item) {
    ?>
	<h2><a href="<?php 
    echo htmlSpecialChars($item->link);
    ?>
"><?php 
    echo htmlSpecialChars($item->title);
    ?>
</a>
	<small><?php 
Beispiel #8
0
<?php

use Cmfcmf\OpenWeatherMap;
use Cmfcmf\OpenWeatherMap\Exception as OWMException;
$app->get('/', function () use($app) {
    $view = [];
    // NEWS SLIDE
    Feed::$cacheExpire = "30 minutes";
    Feed::$cacheDir = "/tmp";
    $rss_npr = Feed::loadRss("http://www.npr.org/rss/rss.php?id=1001");
    $rss_techmeme = Feed::loadRss("http://www.techmeme.com/feed.xml");
    $view['news_npr'] = $rss_npr->item;
    $view['news_techmeme'] = $rss_techmeme->item;
    // WEATHER SLIDE
    $lang = 'en';
    $units = 'imperial';
    $owm = new OpenWeatherMap(null, new WeatherCache(), 60);
    try {
        $weather = $owm->getWeather('Milpitas', $units, $lang, "06b7f9678c0512b3b8ca9e94758a9601");
        $rawForecast = $owm->getWeatherForecast("Milpitas", $units, $lang, "06b7f9678c0512b3b8ca9e94758a9601", 3);
        $forecast = [];
        while ($rawForecast->valid()) {
            $chunk = $rawForecast->current();
            $forecast[] = ['start' => $chunk->time->from->getTimestamp() - 3600 * 8, 'low' => $chunk->temperature->min->getValue(), 'avg' => $chunk->temperature->now->getValue(), 'max' => $chunk->temperature->max->getValue(), 'pressure' => $chunk->pressure->getValue(), 'precipitation' => $chunk->precipitation->getValue(), 'humidity' => $chunk->humidity->getValue(), 'clouds' => $chunk->clouds->getValue()];
            $rawForecast->next();
        }
        $forecastAvg = [];
        $forecastLow = [];
        $forecastHigh = [];
        $forecastPrecip = [];
        $fp = 0.5;
Beispiel #9
0
<?php

$title = 'CRITTER.SPACE';
include 'thatfunk/header.php';
require 'vendor/autoload.php';
use Egulias\EmailValidator\EmailValidator;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$log = new Logger('CRTR.SPACE');
$log->pushHandler(new StreamHandler('../space.log', Logger::DEBUG));
// add records to the log
$log->addInfo('Hit from ' . $_SERVER['REMOTE_ADDR']);
$url = "https://earthbot.net/rss/feed.xml";
$rss = Feed::loadRss($url);
//include ('thatfunk/fakefeed.txt');
echo '<h3 style="text-align: center;">Just updated! <strong>DEC-06-2015</strong></h3><hr>';
echo '<h2 style="text-align: center;">"<a href="https://earthbot.net/chat/">Lots</a> of <a href="http://rogue.news">new</a> <a href="https://earthbot.net/games/">stuff"</a></h2><hr>';
echo '<h2 style="text-align: center;"><a href="http://bugs.earthbot.net">report bugs</a></h2><hr>';
echo '<h3 style="color:green;">PH/TXT: 541- [two] 95-7172</h1><hr>';
echo '<h3 style="color:green;">EMAIL: aerth [at sign] sdf.org</h1><hr>';
echo '<h3 style="color:green;">IM/XMPP: aerth [at sign] earthbot.net </h1><hr>';
?>
<h3>Here is a great radio station I listen to frequently</h3>
<iframe src="http://tunein.com/embed/player/s198870/" style="width:100%;height:100px;" scrolling="no" frameborder="no"></iframe>
<?php 
//echo 'Link: ', $atom->link;
echo '<div class="large-6 small-6 columns" style="padding-left: 1px; padding-right: 1px;margin-right: 0px;margin-left: 0px;">';
echo '<h2>Earthbot\'s Latest Log</h2><p><a href="https://earthbot.net">View on Earthbot</a><hr>';
echo '<rss version="0.92" xml:base="https://earthbot.net/"><link base="https://earthbot.net/">';
foreach ($rss->item as $item) {
    $description = str_replace('<a href="', '<a href="https://earthbot.net/', $item->description);
Beispiel #10
0
    // create template
    $template = $presenter->createTemplate()->setFile(__DIR__ . '/app/' . $lang . '.latte');
    // register template helpers like {$foo|date}
    $template->registerHelper('date', function ($date) use($lang) {
        if ($lang === 'en') {
            return date('F j, Y', (int) $date);
        } else {
            static $months = array(1 => 'leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec');
            $date = getdate((int) $date);
            return "{$date['mday']}. {$months[$date['mon']]} {$date['year']}";
        }
    });
    $template->registerHelper('tweet', function ($s) {
        return Twitter::clickable($s);
    });
    $template->registerHelper('rss', function ($path) {
        return Feed::loadRss($path);
    });
    $template->registerHelper('texy', array(new Texy(), 'process'));
    return $template;
});
// http://davidgrudl.com/sources
$container->router[] = new Route('sources', function ($presenter) {
    $template = $presenter->createTemplate()->setFile(__DIR__ . '/app/sources.latte');
    $template->registerHelper('source', function ($file, $lang = NULL) {
        return preg_replace('#<br ?/?>#', '', highlight_file($file, TRUE));
    });
    return $template;
});
// Run the application!
$container->application->run();
Beispiel #11
0
<?php

header('Content-Type: text/html; charset=utf-8');
require_once 'feed.class.php';
$rss = Feed::loadRss('http://bowdoinorientexpress.com/rss');
?>

<h1><?php 
echo htmlSpecialChars($rss->title);
?>
</h1>

<p><i><?php 
echo htmlSpecialChars($rss->description);
?>
</i></p>

<?php 
foreach ($rss->item as $item) {
    ?>
    <h2><a href="<?php 
    echo htmlSpecialChars($item->link);
    ?>
"><?php 
    echo htmlSpecialChars($item->title);
    ?>
</a>
    <small><?php 
    echo date("j.n.Y H:i", (int) $item->timestamp);
    ?>
</small></h2>
    exit;
}
foreach ($blogFeed->item as $item) {
    $dateTime = new DateTime($item->pubDate);
    if ($dateTime <= $mostRecentBlogDateTime) {
        // break;
    }
    $uniqueBlogCheck = $db->getRead()->fetchValue("SELECT 1 FROM `jpemeric_stream`.`blog` WHERE `permalink` = :guid LIMIT 1", ['guid' => (string) $item->guid]);
    if ($uniqueBlogCheck !== false) {
        continue;
    }
    $dateTime->setTimezone(new DateTimeZone('America/Phoenix'));
    $metadata = json_decode(json_encode($item), true);
    $db->getWrite()->perform("INSERT INTO `jpemeric_stream`.`blog` (`permalink`, `datetime`, `metadata`) " . "VALUES (:permalink, :datetime, :metadata)", ['permalink' => (string) $item->guid, 'datetime' => $dateTime->format('Y-m-d H:i:s'), 'metadata' => json_encode($metadata)]);
}
$mostRecentBlogCommentDateTime = $db->getRead()->fetchValue("SELECT `datetime` FROM `jpemeric_stream`.`blog_comment` ORDER BY `datetime` DESC LIMIT 1");
$mostRecentBlogCommentDateTime = new DateTime($mostRecentBlogCommentDateTime);
$commentFeed = Feed::loadRss('https://blog.jacobemerick.com/rss-comments.xml');
foreach ($commentFeed->item as $item) {
    $dateTime = new DateTime($item->pubDate);
    if ($dateTime <= $mostRecentBlogCommentDateTime) {
        break;
    }
    $uniqueBlogCommentCheck = $db->getRead()->fetchValue("SELECT 1 FROM `jpemeric_stream`.`blog_comment` WHERE `permalink` = :guid LIMIT 1", ['guid' => (string) $item->guid]);
    if ($uniqueBlogCommentCheck !== false) {
        continue;
    }
    $dateTime->setTimezone(new DateTimeZone('America/Phoenix'));
    $metadata = json_decode(json_encode($item), true);
    $db->getWrite()->perform("INSERT INTO `jpemeric_stream`.`blog_comment` (`permalink`, `datetime`, `metadata`) " . "VALUES (:permalink, :datetime, :metadata)", ['permalink' => (string) $item->guid, 'datetime' => $dateTime->format('Y-m-d H:i:s'), 'metadata' => json_encode($metadata)]);
}
Beispiel #13
0
<?php

header('Content-Type: text/html; charset=utf-8');
if (!ini_get('date.timezone')) {
    date_default_timezone_set('Europe/Prague');
}
require_once 'src/Feed.php';
$rss = Feed::loadRss('http://skepdic.ru/feed/');
?>

<h1><?php 
echo htmlSpecialChars($rss->title);
?>
</h1>

<p><i><?php 
echo htmlSpecialChars($rss->description);
?>
</i></p>

<?php 
foreach ($rss->item as $item) {
    ?>
	<h2><a href="<?php 
    echo htmlSpecialChars($item->link);
    ?>
"><?php 
    echo htmlSpecialChars($item->title);
    ?>
</a>
	<small><?php