} } // class RssCron $postgresql = getenv("RSSCOLLECTOR_PGSQL"); if (empty($postgresql)) { $logger->logError("Missing environment variable RSSCOLLECTOR_PGSQL"); exit(1); } $mysql = getenv("RSSCOLLECTOR_MYSQL"); if (empty($mysql)) { $logger->logError("Missing environment variable RSSCOLLECTOR_MYSQL"); exit(1); } // $logger->logDebug ( "Using Postgress at $postgresql and MySql at $mysql" ); $reader = new FeedsPoll($postgresql); $feeds = $reader->poll(); require_once 'FeedReadFilter.php'; $reader = new \Rss\Feed\Reader\Parse($postgresql); $feedfilter = new FeedReadFilter($postgresql); foreach ($feeds as $feedurl) { //$feedurl = "http://world.einnews.com/rss/y4bqah8fsEQ2NjIG"; $logger->logInfo("Starting ({$feedurl})"); $content = $reader->feedParse($feedurl); if (!$content) { $logger->logError("Feed unreadable ({$feedurl})"); continue; } $filtered = $feedfilter->feed_filter($content); } require_once 'FeedPost.php'; exit(0);
// $feedurl = 'http://theconversation.com/uk/politics/articles.atom'; // $feedurl = 'http://www.economist.com/rss/the_world_this_week_rss.xml'; // $feedurl = 'http://praguemonitor.com/rss/1+11+12+13+14+19+143/feed'; // $feedurl = 'http://www.sfgate.com/rss/feeds/news_world.xml'; // $feedurl = 'http://en.gmw.cn/rss_en.xml'; $reader = new \Rss\Feed\Reader\Parse($postgresql); $logger->logInfo("Starting: {$feedurl}"); $content = $reader->feedParse($feedurl); if (!$content) { $logger->logError("Feed unreadable ({$feedurl})"); exit(1); } unset($reader); $logger->logInfo("Fetched ({$feedurl})"); require_once 'FeedReadFilter.php'; $feedfilter = new FeedReadFilter($postgresql, $feedurl); $filtered = $feedfilter->feed_filter($content); unset($content); unset($feedfilter); $filtered = json_encode($filtered, JSON_UNESCAPED_UNICODE); file_put_contents("articles.txt", $filtered); echo $filtered . PHP_EOL; // //unset($filtered); // $tmp = file_get_contents("articles.txt"); // $tmp1 = json_decode($tmp, true); // $tmp1 = json_encode ( $tmp1, JSON_UNESCAPED_UNICODE ); // $countrecovered = fwrite ( STDOUT, $tmp1 ); // fwrite ( STDOUT, PHP_EOL ); // $countoriginal = fwrite ( STDOUT, $filtered ); // fwrite ( STDOUT, PHP_EOL ); // echo PHP_EOL;