本文整理汇总了PHP中SimplePie::set_stupidly_fast方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::set_stupidly_fast方法的具体用法?PHP SimplePie::set_stupidly_fast怎么用?PHP SimplePie::set_stupidly_fast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimplePie
的用法示例。
在下文中一共展示了SimplePie::set_stupidly_fast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SimplePie
function rss_to_activity_streams($data)
{
//
$feed = new SimplePie();
$feed->set_raw_data($data);
//
unset($data);
//
$feed->set_stupidly_fast(true);
$feed->init();
$feed->handle_content_type();
//
$id = md5($url);
$title = 'submit';
$link = 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
$activityStream = new ActivityStreamsDoc($id, $title, $link);
//
foreach ($feed->get_items() as $item) {
$author = $item->get_author();
if (!$author) {
$author = $feed->get_author();
}
//
$activityStream->entry($item->get_id(), date("r", $item->get_date()), $author ? $author->get_name() : null, $author ? $author->get_link() : null, $item->get_title(), $item->get_permalink(), $item->get_description());
}
return $activityStream;
}
示例2: update
public function update() {
$feed = new SimplePie();
$feed->set_feed_url('https://github.com/' . $this->user . '.atom');
$feed->enable_cache(false);
$feed->set_stupidly_fast(true);
$feed->init();
foreach ($feed->get_items() as $item) {
$id = $item->get_id();
$title = substr($item->get_title(), strlen($this->user) + 1);
$title = sprintf('<a href="%s">%s</a>', $item->get_permalink(), $title);
$data = array(
'id' => $id,
'title' => $title,
'content' => $item->get_content(),
'source' => 'github',
'timestamp' => $item->get_date('U')
);
/*$type = substr($id, 20, strpos($id, '/'));
switch ($type) {
case 'PushEvent':
case 'IssueCommentEvent':
case 'PullRequestEvent':
case 'IssuesEvent':
default:
// no-op, standard stuff will work fine
break;
}*/
Murray_Entry::create($data);
}
}
示例3: update
public function update() {
$feed = new SimplePie();
$feed->set_feed_url('http://api.twitter.com/1/statuses/user_timeline.atom?screen_name=' . $this->user);
$feed->enable_cache(false);
$feed->set_stupidly_fast(true);
$feed->init();
foreach ($feed->get_items() as $item) {
$title = substr($item->get_title(), strlen($this->user) + 2);
$title = sprintf('<blockquote>%s</blockquote>', $title);
$data = array(
'id' => $item->get_id(),
'title' => Twitter_Autolink::create($title)
->setTarget(false)
->setExternal(false)
->addLinks(),
'content' => '',
'source' => 'twitter',
'timestamp' => $item->get_date('U')
);
Murray_Entry::create($data);
}
}
示例4: _createSimplePie
/**
* _createSimplePie
*
* @param string &$feed Params
*
* @return object
*/
private function _createSimplePie(&$feed)
{
include_once JPATH_AUTOTWEET . '/libs/SimplePie_autoloader.php';
// Process the feed with SimplePie
$simplePie = new SimplePie();
$simplePie->set_feed_url($feed->xtform->get('url'));
$simplePie->set_stupidly_fast(true);
$simplePie->enable_order_by_date(true);
if ($feed->xtform->get('encoding', 'utf-8')) {
$simplePie->set_input_encoding($feed->xtform->get('encoding'));
}
if ($feed->xtform->get('force_fsockopen')) {
$simplePie->force_fsockopen(true);
}
$use_sp_cache = EParameter::getComponentParam(CAUTOTWEETNG, 'use_sp_cache', true);
if ($use_sp_cache && is_writable(JPATH_CACHE)) {
$simplePie->set_cache_location(JPATH_CACHE);
$simplePie->enable_cache(true);
} else {
$simplePie->enable_cache(false);
}
$set_sp_timeout = EParameter::getComponentParam(CAUTOTWEETNG, 'set_sp_timeout', 10);
if ($set_sp_timeout) {
$simplePie->set_timeout((int) $set_sp_timeout);
}
$simplePie->init();
return $simplePie;
}
示例5: addAllGroupFeed
public function addAllGroupFeed()
{
if (OW::getConfig()->getValue('grouprss', 'disablePosting') == '1') {
return;
}
$commentService = BOL_CommentService::getInstance();
$newsfeedService = NEWSFEED_BOL_Service::getInstance();
$router = OW::getRouter();
$displayText = OW::getLanguage()->text('grouprss', 'feed_display_text');
$location = OW::getConfig()->getValue('grouprss', 'postLocation');
include_once 'autoloader.php';
$allFeeds = $this->feeddao->findAll();
foreach ($allFeeds as $feed) {
$simplefeed = new SimplePie();
$simplefeed->set_feed_url($feed->feedUrl);
$simplefeed->set_stupidly_fast(true);
$simplefeed->enable_cache(false);
$simplefeed->init();
$simplefeed->handle_content_type();
$items = $simplefeed->get_items(0, $feed->feedCount);
foreach ($items as $item) {
$content = UTIL_HtmlTag::autoLink($item->get_content());
if ($location == 'wall' && !$this->isDuplicateComment($feed->groupId, $content)) {
$commentService->addComment('groups_wal', $feed->groupId, 'groups', $feed->userId, $content);
}
if (trim($location) == 'newsfeed' && !$this->isDuplicateFeed($feed->groupId, $content)) {
$statusObject = $newsfeedService->saveStatus('groups', (int) $feed->groupId, $content);
$content = UTIL_HtmlTag::autoLink($content);
$action = new NEWSFEED_BOL_Action();
$action->entityId = $statusObject->id;
$action->entityType = "groups-status";
$action->pluginKey = "newsfeed";
$data = array("string" => $content, "content" => "[ph:attachment]", "view" => array("iconClass" => "ow_ic_comment"), "attachment" => array("oembed" => null, "url" => null, "attachId" => null), "data" => array("userId" => $feed->userId), "actionDto" => null, "context" => array("label" => $displayText, "url" => $router->urlForRoute('groups-view', array('groupId' => $feed->groupId))));
$action->data = json_encode($data);
$actionObject = $newsfeedService->saveAction($action);
$activity = new NEWSFEED_BOL_Activity();
$activity->activityType = NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE;
$activity->activityId = $feed->userId;
$activity->actionId = $actionObject->id;
$activity->privacy = NEWSFEED_BOL_Service::PRIVACY_EVERYBODY;
$activity->userId = $feed->userId;
$activity->visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL;
$activity->timeStamp = time();
$activity->data = json_encode(array());
$activityObject = $newsfeedService->saveActivity($activity);
$newsfeedService->addActivityToFeed($activity, 'groups', $feed->groupId);
}
}
$simplefeed->__destruct();
unset($feed);
}
}
示例6: update_from_feed
protected function update_from_feed($url, $title_format, $title_start = 0) {
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->enable_cache(false);
$feed->set_stupidly_fast(true);
$feed->init();
foreach ($feed->get_items() as $item) {
$title = substr($item->get_title(), $title_start);
$title = sprintf($title_format, $item->get_permalink(), $title);
$data = array(
'id' => $item->get_id(),
'title' => $title,
'content' => '',
'source' => 'reddit',
'timestamp' => $item->get_date('U')
);
Murray_Entry::create($data);
}
}
示例7: update
public function update() {
$feed = new SimplePie();
$feed->set_feed_url('http://ws.audioscrobbler.com/1.0/user/' . $this->user . '/recenttracks.rss');
$feed->enable_cache(false);
$feed->set_stupidly_fast(true);
$feed->init();
foreach ($feed->get_items() as $item) {
$title = sprintf('listened to <a href="%s">%s</a>', $item->get_permalink(), $item->get_title());
$data = array(
'id' => $item->get_id(),
'title' => $title,
'content' => '',
'source' => 'lastfm',
'timestamp' => $item->get_date('U')
);
Murray_Entry::create($data);
}
}
示例8: add_feed
/**
* Add a new feed to the database
*
* Adds the specified feed name and URL to the global <tt>$data</tt> array. If no name is set
* by the user, it fetches one from the feed. If the URL specified is a HTML page and not a
* feed, it lets SimplePie do autodiscovery and uses the XML url returned.
*
* @since 1.0
* @uses $data Contains all feeds, this is what we add the new feed to
*
* @param string $url URL to feed or website (if autodiscovering)
* @param string $name Title/Name of feed
* @param string $cat Category to add feed to
* @param bool $return If true, return the new feed's details. Otherwise, use the global $data array
* @return bool True if succeeded, false if failed
*/
function add_feed($url, $name = '', $cat = 'default', $return = false)
{
if (empty($url)) {
throw new Exception(_r("Couldn't add feed: No feed URL supplied"), Errors::get_code('admin.feeds.no_url'));
}
require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc';
$feed_info = new SimplePie();
$feed_info->set_useragent('Lilina/' . LILINA_CORE_VERSION . '; (' . get_option('baseurl') . '; http://getlilina.org/; Allow Like Gecko) SimplePie/' . SIMPLEPIE_BUILD);
$feed_info->set_stupidly_fast(true);
$feed_info->enable_cache(false);
$feed_info->set_feed_url(urldecode($url));
$feed_info->init();
$feed_error = $feed_info->error();
$feed_url = $feed_info->subscribe_url();
if (!empty($feed_error)) {
//No feeds autodiscovered;
throw new Exception(sprintf(_r("Couldn't add feed: %s is not a valid URL or the server could not be accessed. Additionally, no feeds could be found by autodiscovery."), $url), Errors::get_code('admin.feeds.invalid_url'));
}
if (empty($name)) {
//Get it from the feed
$name = $feed_info->get_title();
}
if ($return === true) {
return array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'name' => $name, 'cat' => $cat);
}
global $data;
$data['feeds'][] = array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'name' => $name, 'cat' => $cat);
save_feeds();
return sprintf(_r('Added feed "%1$s"'), $name);
}
示例9: upgrade_single
protected function upgrade_single($feed)
{
require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
$sp = new SimplePie();
$sp->set_useragent(LILINA_USERAGENT . ' SimplePie/' . SIMPLEPIE_BUILD);
$sp->set_stupidly_fast(true);
$sp->set_cache_location(get_option('cachedir'));
$sp->set_favicon_handler(get_option('baseurl') . '/lilina-favicon.php');
$sp->set_feed_url($feed['feed']);
$sp->init();
if (!isset($feed['icon'])) {
$feed['icon'] = $sp->get_favicon();
}
return $feed;
}
示例10: isset
function lmm_dashboard_widget()
{
global $wpdb;
$lmm_options = get_option('leafletmapsmarker_options');
$table_name_markers = $wpdb->prefix . 'leafletmapsmarker_markers';
$widgets = get_option('dashboard_widget_options');
$widget_id = 'lmm-admin-dashboard-widget';
$number_of_markers = isset($widgets[$widget_id]) && isset($widgets[$widget_id]['items']) ? absint($widgets[$widget_id]['items']) : 4;
$result = $wpdb->get_results($wpdb->prepare("SELECT `id`,`markername`,`icon`,`createdon`,`createdby` FROM `{$table_name_markers}` ORDER BY `createdon` desc LIMIT %d", $number_of_markers), ARRAY_A);
echo '<p><a style="background:#f99755;display:block;padding:5px;text-decoration:none;color:#2702c6;text-align:center;" href="' . LEAFLET_WP_ADMIN_URL . 'admin.php?page=leafletmapsmarker_pro_upgrade">' . __('Upgrade to pro version for even more features - click here to find out how you can start a free 30-day-trial easily', 'lmm') . '</a><hr style="border:0;height:1px;background-color:#d8d8d8;"/></p>';
if ($result != NULL) {
echo '<table style="margin-bottom:5px;"><tr>';
foreach ($result as $row) {
$icon = $row['icon'] == NULL ? LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png' : LEAFLET_PLUGIN_ICONS_URL . '/' . $row['icon'];
echo '<td><a href="' . LEAFLET_WP_ADMIN_URL . 'admin.php?page=leafletmapsmarker_marker&id=' . $row['id'] . '" title="' . esc_attr__('edit marker', 'lmm') . '"><img src="' . $icon . '" style="width:80%;"></a>';
echo '<td style="vertical-align:top;line-height:1.2em;">';
echo '<a href="' . LEAFLET_WP_ADMIN_URL . 'admin.php?page=leafletmapsmarker_marker&id=' . $row['id'] . '" title="' . esc_attr__('edit marker', 'lmm') . '">' . htmlspecialchars(stripslashes($row['markername'])) . '</a><br/>' . __('created on', 'lmm') . ' ' . date("Y-m-d - h:m", strtotime($row['createdon'])) . ', ' . __('created by', 'lmm') . ' ' . $row['createdby'];
echo '</td></tr>';
}
echo '</table>';
} else {
echo '<p style="margin-bottom:5px;">' . __('No marker created yet', 'lmm') . '</p>';
}
if (!isset($widgets[$widget_id]['blogposts'])) {
$show_rss = 1;
} else {
if (isset($widgets[$widget_id]['blogposts']) && $widgets[$widget_id]['blogposts'] == 1) {
$show_rss = 0;
} else {
$show_rss = 1;
}
}
//info: use custom name to prevent false malware detection by WordFence plugin
function lmm_spc_custom_name($string)
{
return 'mapsmarker-dashboard-widget-rss-item-cache';
}
if ($show_rss == 1) {
require_once ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-simplepie.php';
$feed = new SimplePie();
if (file_exists(LEAFLET_PLUGIN_ICONS_DIR . DIRECTORY_SEPARATOR . 'readme-icons.txt')) {
$feed->enable_cache(true);
$feed->set_cache_location($location = LEAFLET_PLUGIN_ICONS_DIR);
$feed->set_cache_name_function('lmm_spc_custom_name');
$feed->set_cache_duration(86400);
} else {
$feed->enable_cache(false);
}
$feed->set_feed_url('http://feeds.feedburner.com/MapsMarkerPro');
$feed->set_stupidly_fast(true);
$feed->enable_order_by_date(true);
$feed->init();
$feed->handle_content_type();
echo '<hr style="border:0;height:1px;background-color:#d8d8d8;"/><strong><p>' . __('Latest blog posts from www.mapsmarker.com', 'lmm') . '</p></strong>';
if ($feed->get_items() == NULL) {
$blogpost_url = '<a href="https://www.mapsmarker.com/news" target="_blank">https://www.mapsmarker.com/news</a>';
echo sprintf(__('Feed could not be retrieved, please try again later or read the latest blog posts at %s', 'lmm'), $blogpost_url);
}
foreach ($feed->get_items(0, 3) as $item) {
echo '<p style="margin:0.5em 0;">' . $item->get_date('j F Y') . ': <strong><a href="' . $item->get_permalink() . '?ref=dashboard">' . $item->get_title() . '</a></strong></p>' . PHP_EOL;
}
echo '<p><a style="text-decoration:none;" href="https://www.mapsmarker.com" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-website-home.png" width="16" height="16" alt="mapsmarker.com"> MapsMarker.com</a> <a href="' . LEAFLET_WP_ADMIN_URL . 'admin.php?page=leafletmapsmarker_pro_upgrade' . '"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-up16.png" width="16" height="16" alt="upgrade to pro"> ' . __('Upgrade to Pro', 'lmm') . '</a> <a style="text-decoration:none;" title="' . esc_attr__('MapsMarker affiliate program - sign up now and receive commissions up to 50%!', 'lmm') . '" href="https://www.mapsmarker.com/affiliates" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-affiliates.png" width="16" height="16" alt="affiliates"> ' . __('Affiliates', 'lmm') . '</a> <a style="text-decoration:none;" title="' . esc_attr__('MapsMarker reseller program - re-sell with a 20% discount!', 'lmm') . '" href="https://www.mapsmarker.com/reseller" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-resellers.png" width="16" height="16" alt="resellers"> ' . __('Resellers', 'lmm') . '</a> <a style="text-decoration:none;" href="https://www.mapsmarker.com/reviews" target="_blank" title="' . esc_attr__('please rate this plugin on wordpress.org', 'lmm') . '"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-star.png" width="16" height="16" alt="ratings"> ' . __('rate plugin', 'lmm') . '</a> <a href="https://translate.mapsmarker.com/projects/lmm" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-translations.png" width="16" height="16" alt="translations"> ' . __('translations', 'lmm') . '</a> <a href="https://twitter.com/mapsmarker" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-twitter.png" width="16" height="16" alt="twitter"> Twitter</a> <a href="https://facebook.com/mapsmarker" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-facebook.png" width="16" height="16" alt="facebook"> Facebook</a> <a href="https://www.mapsmarker.com/+" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-google-plus.png" width="16" height="16" alt="google+"> Google+</a> <a style="text-decoration:none;" href="https://www.mapsmarker.com/changelog" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-changelog-header.png" width="16" height="16" alt="changelog"> ' . __('Changelog', 'lmm') . '</a> <a href="https://feeds.feedburner.com/MapsMarker" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-rss.png" width="16" height="16" alt="rss"> RSS</a> <a href="http://feedburner.google.com/fb/a/mailverify?uri=MapsMarker" target="_blank"><img src="' . LEAFLET_PLUGIN_URL . 'inc/img/icon-rss-email.png" width="16" height="16" alt="rss-email"> ' . __('E-Mail', 'lmm') . '</a></p>';
}
}
示例11: GCal
/**
* Constructor
*
*/
function GCal()
{
// depricated
//global $TMPL;
$this->EE =& get_instance();
/** ---------------------------------------
/** Fetch parameters
/** ---------------------------------------*/
$this->gcal_id = ($gcal_id = $this->EE->TMPL->fetch_param('gcal_id')) === FALSE ? $this->gcal_id : html_entity_decode($gcal_id);
$this->refresh = ($refresh = $this->EE->TMPL->fetch_param('refresh')) === FALSE ? $this->refresh : $refresh;
$this->limit = ($limit = $this->EE->TMPL->fetch_param('limit')) === FALSE ? $this->limit : $limit;
$this->show_future = ($show_future = $this->EE->TMPL->fetch_param('show_future')) === FALSE ? $this->show_future : $show_future;
$this->orderby = ($orderby = $this->EE->TMPL->fetch_param('orderby')) === FALSE ? $this->orderby : $orderby;
$this->sort_order = ($sort_order = $this->EE->TMPL->fetch_param('sort_order')) === FALSE ? $this->sort_order : $sort_order;
$this->startmin = ($startmin = $this->EE->TMPL->fetch_param('from')) === FALSE ? $this->startmin : $startmin;
$this->startmax = ($startmax = $this->EE->TMPL->fetch_param('to')) === FALSE ? $this->startmax : $startmax;
if (strlen($this->gcal_id) < 1) {
$this->EE->TMPL->log_item("GCal error: Invalid URL");
$this->return_data = '';
return;
}
/** ---------------------------------------
/** Create the full url
/** ---------------------------------------*/
$url = 'http://www.google.com/calendar/feeds/' . $this->gcal_id . '/public/full?orderby=' . $this->orderby;
$url .= '&sortorder=' . $this->sort_order . '&futureevents=' . $this->show_future;
if ($this->startmin != '') {
$this->startmin = urlencode(date('c', strtotime($this->startmin)));
$url .= '&start-min=' . $this->startmin;
}
if ($this->startmax != '') {
$this->startmax = urlencode(date('c', strtotime($this->startmax)));
$url .= '&start-max=' . $this->startmax;
}
/** ---------------------------------------
/** Fetch the XML from Google
/** ---------------------------------------*/
if (($rawxml = $this->_check_cache($url)) === FALSE) {
$this->cache_expired = TRUE;
$this->EE->TMPL->log_item("Fetching Google Calendar remotely");
if (function_exists('curl_init')) {
$rawxml = $this->_curl_fetch($url);
} else {
$rawxml = $this->_fsockopen_fetch($url);
}
}
if ($rawxml == '' or substr($rawxml, 0, 5) != "<?xml") {
$this->EE->TMPL->log_item("GCal error: Unable to retreive feed from Google => " . $rawxml);
$this->return_data = '';
return;
}
/** ---------------------------------------
/** Write cache
/** ---------------------------------------*/
if ($this->cache_expired == TRUE) {
$this->_write_cache($rawxml, $url);
}
/** ---------------------------------------
/** Parse the XML with SimplePie
/** ---------------------------------------*/
if (!class_exists('SimplePie')) {
$this->EE->TMPL->log_item("GCal error: this plugin requires SimplePie v1.0 or greater");
$this->return_data = '';
return;
}
$feed = new SimplePie();
//$cache_dir = APP_CACHE.$this->cache_name.'/';
$cache_dir = APPPATH . 'cache/' . $this->cache_name . '/';
$feed->set_cache_location($cache_dir);
$feed->set_stupidly_fast(TRUE);
// skips some sanity checks; may not be a good idea ... ?
$feed->set_feed_url($url);
$feed->init();
$this->_load_events($feed);
/** ---------------------------------------
/** Go go go!
/** ---------------------------------------*/
$this->return_data = $this->_parse_events();
}
示例12: getFeedData
public static function getFeedData($params)
{
$rssurl = str_replace("\n", ",", JString::trim($params->get('rssurl', '')));
$feedTimeout = (int) $params->get('feedTimeout', 10);
$rssdateorder = (int) $params->get('rssdateorder', 1);
$dformat = $params->get('dformat', '%d %b %Y %H:%M %P');
$rssperfeed = (int) $params->get('rssperfeed', 3);
$textfilter = JString::trim($params->get('textfilter', ''));
$pagination = (int) $params->get('pagination', 0);
$totalfeeds = (int) $params->get('rssitems', 5);
$filtermode = (int) $params->get('filtermode', 0);
$showfeedinfo = (int) $params->get('showfeedinfo', 1);
$input_encoding = JString::trim($params->get('inputencoding', ''));
$showimage = (int) $params->get('rssimage', 1);
$cacheTime = (int) $params->get('feedcache', 15) * 60;
//minutes
$orderBy = $params->get('orderby', 'date');
$tmzone = (int) $params->get('tmzone', 0) ? true : false;
$cachePath = JPATH_SITE . DS . 'cache' . DS . 'mod_we_ufeed_display';
$start = $end = 0;
if ($pagination) {
$pagination_items = (int) $params->get('paginationitems', 5);
$current_limit = modFeedShowHelper::getPage($params->get('mid', 0));
$start = ($current_limit - 1) * $pagination_items;
$end = $current_limit * $pagination_items;
}
#Get clean array
$rss_urls = @array_filter(explode(",", $rssurl));
#If only 1 link, use totalfeeds for total limit
if (count($rss_urls) == 1) {
$rssperfeed = $totalfeeds;
}
# Intilize RSS Doc
if (!class_exists('SimplePie')) {
jimport('simplepie.simplepie');
}
//Parser Code
$simplepie = new SimplePie();
$simplepie->set_cache_location($cachePath);
$simplepie->set_cache_duration($cacheTime);
$simplepie->set_stupidly_fast(true);
$simplepie->force_feed(true);
//$simplepie->force_fsockopen(false); //gives priority to CURL if is installed
$simplepie->set_timeout($feedTimeout);
$simplepie->set_item_limit($rssperfeed);
$simplepie->enable_order_by_date(false);
if ($input_encoding) {
$simplepie->set_input_encoding($input_encoding);
$simplepie->set_output_encoding('UTF-8');
}
$simplepie->set_feed_url($rss_urls);
$simplepie->init();
$rssTotalItems = (int) $simplepie->get_item_quantity($totalfeeds);
if ((int) $params->get('debug', 0)) {
echo "<h3>Total RSS Items:" . $rssTotalItems . "</h3>";
echo print_r($simplepie, true);
#debug
}
if (get_class($simplepie) != 'SimplePie' || !$rssTotalItems) {
return array("rsstotalitems" => 0, 'items' => false);
}
$feedItems = array();
#store all feeds items
$counter = 1;
foreach ($simplepie->get_items($start, $end) as $key => $feed) {
#Word Filter
if (!empty($textfilter) && $filtermode != 0) {
$filter = modFeedShowHelper::filterItems($feed, $textfilter);
#Include #Exclude
if ($filtermode == 1 && !$filter || $filtermode == 2 && $filter) {
$rssTotalItems--;
continue;
#Include
}
}
$FeedValues[$key] = new stdClass();
# channel header and link
$channel = $feed->get_feed();
$FeedValues[$key]->FeedTitle = $channel->get_title();
$FeedValues[$key]->FeedLink = $channel->get_link();
if ($showfeedinfo) {
$FeedValues[$key]->FeedFavicon = 'http://g.etfv.co/' . urlencode($FeedValues[$key]->FeedLink);
}
$FeedValues[$key]->FeedDescription = $channel->get_description();
$FeedValues[$key]->FeedLogo = $channel->get_image_url();
#Item
$FeedValues[$key]->ItemTitle = $feed->get_title();
$feeDateUNIX = $feed->get_date('U');
if ($feeDateUNIX < 1) {
$feeDateUNIX = strtotime(trim(str_replace(",", "", $feed->get_date(''))));
}
$FeedValues[$key]->ItemDate = WEJM16 ? JHTML::_('date', $feeDateUNIX, $dformat, $tmzone) : JHtml::date($feeDateUNIX, $dformat, $tmzone);
$FeedValues[$key]->ItemLink = $feed->get_link();
//$feed->get_permalink();
$FeedValues[$key]->ItemText = $feed->get_description();
$FeedValues[$key]->ItemFulltext = $feed->get_content();
$FeedValues[$key]->ItemEnclosure = $feed->get_enclosure();
$FeedValues[$key]->ItemEnclosures = $feed->get_enclosures();
if ($showimage) {
$FeedValues[$key]->ItemImage = "";
//.........这里部分代码省略.........
示例13: testPostFromTemplate
/**
* Test creating a very sparse post
*
* Only has the defaults, and nothing more
* @dataProvider examplePostProvider
* @param string $post Path to post template
*/
public function testPostFromTemplate($post)
{
// Grab the correct collection
$available = self::getCollectionsFromDocument($this->document);
$proper = null;
foreach ($available as $name => $collection) {
if (in_array(AtomPubHelper::AtomEntryMediaType, $collection['accepted'])) {
$proper = $collection;
break;
}
}
$this->assertNotNull($proper);
$collection = $proper;
Gorilla::$runner->report(Gorilla_Runner::REPORT_INFO, 'Creating from ' . str_replace(Gorilla::$path, 'Gorilla', $post));
// Get the template data
$data = file_get_contents($post);
// Load it up
$entry = AtomPubHelper_Entry::from_template($data);
// Give it a random ID
$entry->set_element('id', 'tag:ryanmccue.info,2012:' . sprintf("%06d%06d", rand(0, 100000), rand(0, 100000)));
$entry->set_element('updated', date('c'));
$headers = array('Content-Type' => AtomPubHelper::AtomEntryMediaType);
// Generate a random slug (we'll check this later)
$slug_num = sprintf("%06d", rand(0, 100000));
$slug = 'ape-' . $slug_num;
$slug_re = '#ape.?' . $slug_num . '#i';
$headers['Slug'] = $slug;
// Convert to XML
$data = $entry->serialize_xml();
Gorilla::$runner->report(Gorilla_Runner::REPORT_DEBUG, "Submitting entry:\n" . $data);
// And then POST it to create it
$poster = Requests::post($collection['href'], $headers, $data, self::requestsOptions());
$this->assertEquals(201, $poster->status_code, 'Could not create new post: ' . $poster->body);
$this->assertNotEmpty($poster->headers['location']);
Gorilla::$runner->report(Gorilla_Runner::REPORT_INFO, 'Posting of new entry reported success, location: ' . $poster->headers['location']);
// Check the data we got from the POST request
Gorilla::$runner->report(Gorilla_Runner::REPORT_INFO, 'Examining the new entry as returned in the POST response');
$wrapped = AtomPubHelper::wrap_entry($poster->body);
$sp = new SimplePie();
$sp->set_raw_data($wrapped);
$sp->set_stupidly_fast();
$sp->init();
$this->assertNull($sp->error(), 'New entry is not well-formed: ' . $sp->error());
$remote_entry = $sp->get_item(0);
$this->checkEntry($entry, $remote_entry);
$found = false;
foreach ($remote_entry->get_links() as $link) {
if (preg_match($slug_re, $link) > 0) {
$found = true;
break;
}
}
if ($found) {
Gorilla::$runner->report(Gorilla_Runner::REPORT_INFO, 'Slug was used in server-generated URI');
} else {
Gorilla::$runner->report(Gorilla_Runner::REPORT_WARNING, 'Slug not used in server-generated URI');
}
// And now check at the new location!
Gorilla::$runner->report(Gorilla_Runner::REPORT_INFO, 'Checking at the new location');
$new = Requests::get($poster->headers['location'], array(), array(), self::requestsOptions());
$this->assertEquals(200, $new->status_code, 'New post not found at location');
$wrapped = AtomPubHelper::wrap_entry($new->body);
$sp = new SimplePie();
$sp->set_raw_data($wrapped);
$sp->set_stupidly_fast();
$sp->init();
$this->assertNull($sp->error(), 'New entry is not well-formed: ' . $sp->error());
$remote_entry = $sp->get_item(0);
$this->checkEntry($entry, $remote_entry);
}
示例14: fetchFeed
/**
* Parses a feed with SimplePie
*
* @param boolean $stupidly_fast Set fast mode. Best for checks
* @param integer $max Limit of items to fetch
* @return SimplePie_Item Feed object
**/
function fetchFeed($url, $stupidly_fast = false, $max = 0)
{
# SimplePie
if (!class_exists('SimplePie')) {
require_once WPOINC . 'simplepie/simplepie.class.php';
}
$feed = new SimplePie();
$feed->enable_order_by_date(false);
// thanks Julian Popov
$feed->set_feed_url($url);
$feed->set_item_limit($max);
$feed->set_stupidly_fast($stupidly_fast);
$feed->enable_cache(false);
$feed->init();
$feed->handle_content_type();
return $feed;
}
示例15: load
/**
* Create a new SimplePie object
*
* Creates an instance of SimplePie with Items::$feeds
*
* @since 1.0
*/
public function load()
{
global $lilina;
require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc';
$feed = new SimplePie();
$feed->set_useragent('Lilina/' . $lilina['core-sys']['version'] . '; (' . get_option('baseurl') . '; http://getlilina.org/; Allow Like Gecko) SimplePie/' . SIMPLEPIE_BUILD);
$feed->set_stupidly_fast(true);
$feed->set_cache_location(get_option('cachedir'));
$feed->set_favicon_handler(get_option('baseurl') . '/lilina-favicon.php');
$feed = apply_filters('simplepie-config', $feed);
$feed->set_feed_url($this->feeds);
$feed->init();
/** We need this so we have something to work with. */
$feed->get_items();
if (!isset($feed->data['ordered_items'])) {
$feed->data['ordered_items'] = $feed->data['items'];
}
/** Let's force sorting */
usort($feed->data['ordered_items'], array(&$feed, 'sort_items'));
usort($feed->data['items'], array(&$feed, 'sort_items'));
$this->simplepie = $feed;
/** Free up memory just in case */
unset($feed);
}