function fetchFeedDirect() { $url = $_GET["url"]; if (isset($_POST["url"])) { $url = $_POST["url"]; } $reader = new RssReader(); $rss = $reader->fetch_json($url); /* require_once('config/site.php'); if($memcache){ $logger = LogUtil::getLogger(); $mem = new BitMemCache(); if($mem->init()){ $logger->info("init 1"); $logger = LogUtil::getLogger(); $ret = $mem->set($url,$rss ); $logger->info("single update memcache $url ------------[ $ret ]"); $logger->info($mem->get($url)); } }*/ echo $rss; }
function updateMemcache() { // ignore_user_abort(); //set_time_limit(0); //$interval=3600; //(seconds) require_once 'model/Feed.php'; require_once 'lib/BitMemCache.php'; require_once 'lib/RssReader.php'; $feed = new Feed(); $feeds = $feed->getFeeds(); $logger = LogUtil::getLogger(); //do{ include "config/site.php"; foreach ($feeds as $feed) { $url = $feed['url']; $mem = new BitMemCache(); $reader = new RssReader(); $rss = $reader->fetch($url); if (!$rss) { } else { if ($mem->init()) { $mem->set($url, json_encode($rss)); $logger->info("update memcache {$url}"); } } } // sleep($interval); //}while($memcache); }
function Dwoo_Plugin_rss(Dwoo_Core $dwoo, $feed, $assign = 'rss_items', $limit = 5, $cacheTime = 60) { $cacheKey = 'rss:' . $feed; if (false === ($rss = Cache::fetch($cacheKey))) { $rss = new RssReader(); $rss->load($feed); Cache::store($cacheKey, $rss, $cacheTime); } if ($limit) { $dwoo->assignInScope(array_slice($rss->getItems(), 0, $limit), $assign); } else { $dwoo->assignInScope($rss->getItems(), $assign); } return ''; }
function __construct($data = '') { $this->ext_tags = array('yweather:location', 'yweather:units', 'yweather:wind', 'yweather:atmosphere', 'yweather:astronomy', 'yweather:condition', 'yweather:forecast', 'geo:lat', 'geo:long'); parent::__construct($data); }
{ // public function getItem($url) { $page = $this->getPage($url); var_dump($page); die; $item = preg_match_all("@(<item>)(.*)(</item>)@iUs", $page); //$tit = $this->parseTitle($url); var_dump($item); die; foreach ($item as $i) { var_dump($i); } } private function parseTitle($url) { $title = "feeds.bbci.co.uk/news/technology/rss.xml"; return $title; } public function getPage($url) { $page = file_get_contents($url); return $page; } } $rss = new RssReader(); $baseurl = "http://feeds.bbci.co.uk/news/technology/rss.xml"; //$pg = $rss->getPage($baseurl); $rss->getItem($baseurl); ob_flush();
<?php if (empty($pluginManager->getCommand(0)) || !is_numeric($pluginManager->getCommand(0))) { die('{"redirect":["' . $pluginManager->getPluginName() . '", "home", ""]}'); } require_once $pluginManager->getController("RssReader"); $id = $pluginManager->getCommand(0); $value = $pluginManager->databaseManager->getValues(array("id" => array("operator" => "=", "value" => $id)), 1); $rss = new RssReader(); $feedArray = $rss->getFeedArray($value['url']); $returnString = ""; foreach ($feedArray as $feed) { if (strpos($feed['title'], "[Anzeige]") === false) { $returnString .= '{"type":"headingSmall", "value":' . json_encode($feed['title']) . '},'; $returnString .= '{"type":"text", "value":' . json_encode($feed['summary']) . '},'; $returnString .= '{"type":"link", "value":"Weiterlesen ...", "click":"openUrl(\'' . $feed['link'] . '\')"},'; $returnString .= '{"type":"nl"},{"type":"nl"},'; } } $returnString = substr($returnString, 0, -1); ?> [ <?php echo $returnString; ?> ]
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span> <div class="clearfix"></div> </div> </a> </div> </div> </div> </div> </div> <?php } else { $news_rss_obj = new RssReader(array("rss_url" => "http://localhost/wordpress/feed/", "show_limit" => 1)); $news_rss = $news_rss_obj->get_result(); $learning_rss_obj = new RssReader(array("rss_url" => "http://localhost/wordpress/feed/", "show_limit" => 1)); $learning_rss = $learning_rss_obj->get_result(); ?> <div class="row"> <div class="col-md-7"> <h3 class="yekan"><i class="fa fa-rss fa-fw"></i> اخبار و اطلاعیه ها</h3> <hr> <?php // TODO on host, change limit to 2 for ($counter = 0; $counter < 1; ++$counter) { echo '<div class="bs-callout bs-callout-danger pointer_cursor" id="callout-progress-animation-css3"'; echo 'onclick="window.location =\'' . $news_rss[$counter][1] . '\'">'; echo '<h4>' . $news_rss[$counter][0] . '</h4>'; echo "<p>" . $news_rss[$counter][2] . "</p></div>"; }
function __construct($data = '') { $this->ext_tags = array('media:thumbnail', 'media:group', 'media:content'); parent::__construct($data); }
function fn_get_rss_feed($data) { if (!empty($data['feed_url'])) { $data_key = 'rss_data_cache_' . (isset($data['block_data']['block_id']) ? $data['block_data']['block_id'] : 0); Registry::register_cache($data_key, SECONDS_IN_HOUR, CACHE_LEVEL_TIME); if (Registry::is_exist($data_key) == false) { $limit = !empty($data['max_item']) ? $data['max_item'] : 3; static $included; if (empty($included)) { require DIR_CORE . 'class.rss_reader.php'; $included = true; } $rss = new RssReader(); $rss->loadData($data['feed_url']); $rss_items = $rss->getItems(); if (!empty($rss_items)) { $rss_items = array_slice($rss_items, 0, $limit); $rss_chanel = $rss->getChannel(); $rss_data = array(array($rss_items, $rss_chanel['link'], $data['feed_url'])); Registry::set($data_key, $rss_data); return $rss_data; } } else { return Registry::get($data_key); } } return array(); }
<?php include 'RssReader.php'; session_start(); $response = array(); //check is a user has login and a rss feed url needed to retrieve rss content if (isset($_SESSION['username']) && $_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['feedurl'])) { //parse rss feed $rss = new RssReader(trim($_POST['feedurl'])); $rsscontent = $rss->getRssContent(); if ($rsscontent) { //return parsed rss feed result in a json string $response['status'] = "good"; $response['info'] = $rsscontent; } else { $response['status'] = "error"; $response['info'] = "rss"; } } else { $response['status'] = "error"; $response['info'] = "unkown"; } echo json_encode($response);