本文整理汇总了PHP中SimplePie::get_item方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::get_item方法的具体用法?PHP SimplePie::get_item怎么用?PHP SimplePie::get_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimplePie
的用法示例。
在下文中一共展示了SimplePie::get_item方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: respond
public function respond()
{
$url = trim($this->matches[1]);
$index = 0;
if (isset($this->matches[2])) {
$index = intval(trim($this->matches[2]));
$index = $index - 1;
$index = max(0, $index);
}
$error_level = error_reporting();
error_reporting($error_level ^ E_USER_NOTICE);
$feed = new \SimplePie();
if ($this->cacheEnabled()) {
$feed->set_cache_location($this->config['cache_directory']);
$feed->set_cache_duration(600);
}
$feed->set_feed_url($url);
$feed->init();
$feed->handle_content_type();
if ($index > $feed->get_item_quantity() - 1) {
$index = $feed->get_item_quantity() - 1;
}
$item = $feed->get_item($index);
$result = null;
if ($item) {
$title = html_entity_decode($item->get_title());
$link = $item->get_permalink();
$date = $item->get_date();
$i = $index + 1;
$result = "[{$i}] {$date} - {$title} - {$link}";
}
error_reporting($error_level);
return $result;
}
示例2: getFeeds
function getFeeds()
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_jce');
$limit = $params->get('feed_limit', 2);
$feeds = array();
$options = array('rssUrl' => 'http://www.joomlacontenteditor.net/news/feed/rss/latest-news?format=feed', 'cache_time' => $params->get('feed_cachetime', 86400));
// use this directly instead of JFactory::getXMLParserto avoid the feed data error
jimport('simplepie.simplepie');
if (!is_writable(JPATH_BASE . '/cache')) {
$options['cache_time'] = 0;
}
$rss = new SimplePie($options['rssUrl'], JPATH_BASE . '/cache', isset($options['cache_time']) ? $options['cache_time'] : 0);
$rss->force_feed(true);
$rss->handle_content_type();
if ($rss->init()) {
$count = $rss->get_item_quantity();
if ($count) {
$count = $count > $limit ? $limit : $count;
for ($i = 0; $i < $count; $i++) {
$feed = new StdClass();
$item = $rss->get_item($i);
$feed->link = $item->get_link();
$feed->title = $item->get_title();
$feed->description = $item->get_description();
$feeds[] = $feed;
}
}
}
return $feeds;
}
示例3: getRssFeed
/**
* @param $rssURL
* @param $max
* @return array|bool
*/
public static function getRssFeed($rssURL, $max, $cache_time)
{
//if (JVM_VERSION < 3){
$erRep = tsmConfig::setErrorReporting(false, true);
jimport('simplepie.simplepie');
$rssFeed = new SimplePie($rssURL);
$feeds = array();
$count = $rssFeed->get_item_quantity();
$limit = min($max, $count);
for ($i = 0; $i < $limit; $i++) {
$feed = new StdClass();
$item = $rssFeed->get_item($i);
$feed->link = $item->get_link();
$feed->title = $item->get_title();
$feed->description = $item->get_description();
$feeds[] = $feed;
}
if ($erRep[0]) {
ini_set('display_errors', $erRep[0]);
}
if ($erRep[1]) {
error_reporting($erRep[1]);
}
return $feeds;
/*} else {
jimport('joomla.feed.factory');
$feed = new JFeedFactory;
$rssFeed = $feed->getFeed($rssURL,$cache_time);
if (empty($rssFeed) or !is_object($rssFeed)) return false;
for ($i = 0; $i < $max; $i++) {
if (!$rssFeed->offsetExists($i)) {
break;
}
$feed = new StdClass();
$uri = (!empty($rssFeed[$i]->uri) || !is_null($rssFeed[$i]->uri)) ? $rssFeed[$i]->uri : $rssFeed[$i]->guid;
$text = !empty($rssFeed[$i]->content) || !is_null($rssFeed[$i]->content) ? $rssFeed[$i]->content : $rssFeed[$i]->description;
$feed->link = $uri;
$feed->title = $rssFeed[$i]->title;
$feed->description = $text;
$feeds[] = $feed;
}
return $feeds;
}*/
}
示例4: date
/**
* Method description
*
* @param $service_id id of the service, we're about to use
* @param $service_type_id of the service, we're about to use
* @param $feed_url the url of the feed
* @param $items_per_feed maximum number of items that are fetched from the feed
* @param $items_max_age maximum age of any item that is fetched from feed, in days
* @return
* @access
*/
function feed2array($username, $service_id, $service_type_id, $feed_url, $items_per_feed = 5, $items_max_age = '-21 days')
{
if (!$feed_url) {
return false;
}
# get info about service type
$max_age = $items_max_age ? date('Y-m-d H:i:s', strtotime($items_max_age)) : null;
$items = array();
$feed = new SimplePie();
$feed->set_cache_location(CACHE . 'simplepie');
$feed->set_feed_url($feed_url);
$feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
$feed->init();
if ($feed->error() || $feed->feed_url != $feed_url) {
return false;
}
for ($i = 0; $i < $feed->get_item_quantity($items_per_feed); $i++) {
$feeditem = $feed->get_item($i);
# create a NoseRub item out of the feed item
$item = array();
$item['datetime'] = $feeditem->get_date('Y-m-d H:i:s');
if ($max_age && $item['datetime'] < $max_age) {
# we can stop here, as we do not expect any newer items
break;
}
$item['title'] = $feeditem->get_title();
$item['url'] = $feeditem->get_link();
$item['intro'] = @$intro;
$item['type'] = @$token;
$item['username'] = $username;
$service = $this->getService($service_id);
if ($service) {
$item['content'] = $service->getContent($feeditem);
if ($service instanceof TwitterService) {
$item['title'] = $item['content'];
}
} else {
$item['content'] = $feeditem->get_content();
}
$items[] = $item;
}
unset($feed);
return $items;
}
示例5: getRssFeed
/**
* @param $rssURL
* @param $max
* @return array|bool
*/
static public function getRssFeed($rssURL, $max) {
if (JVM_VERSION < 3){
jimport('simplepie.simplepie');
$rssFeed = new SimplePie($rssURL);
$feeds = array();
$count = $rssFeed->get_item_quantity();
$limit=min($max,$count);
for ($i = 0; $i < $limit; $i++) {
$feed = new StdClass();
$item = $rssFeed->get_item($i);
$feed->link = $item->get_link();
$feed->title = $item->get_title();
$feed->description = $item->get_description();
$feeds[] = $feed;
}
return $feeds;
} else {
jimport('joomla.feed.factory');
$feed = new JFeedFactory;
$rssFeed = $feed->getFeed($rssURL);
if (empty($rssFeed) or !is_object($rssFeed)) return false;
for ($i = 0; $i < $max; $i++) {
if (!$rssFeed->offsetExists($i)) {
break;
}
$feed = new StdClass();
$uri = (!empty($rssFeed[$i]->uri) || !is_null($rssFeed[$i]->uri)) ? $rssFeed[$i]->uri : $rssFeed[$i]->guid;
$text = !empty($rssFeed[$i]->content) || !is_null($rssFeed[$i]->content) ? $rssFeed[$i]->content : $rssFeed[$i]->description;
$feed->link = $uri;
$feed->title = $rssFeed[$i]->title;
$feed->description = $text;
$feeds[] = $feed;
}
return $feeds;
}
}
示例6: Folder
function feed_paginate($feed_url, $start = 0, $limit = 5)
{
//make the cache dir if it doesn't exist
if (!file_exists($this->cache)) {
$folder = new Folder($this->cache, true);
}
//include the vendor class
App::import('Vendor', 'simplepie/simplepie');
//setup SimplePie
$feed = new SimplePie();
$feed->set_feed_url($feed_url);
$feed->set_cache_location($this->cache);
//retrieve the feed
$feed->init();
//limits
$max = $start + $limit;
$items['title'] = $feed->get_title();
$items['image_url'] = $feed->get_image_url();
$items['image_height'] = $feed->get_image_height();
$items['image_width'] = $feed->get_image_width();
//$items['title'] = $feed->get_title();
//get the feed items
$items['quantity'] = $feed->get_item_quantity();
if ($items['quantity'] < $start) {
$items['items'] = false;
return $items;
} elseif ($items['quantity'] < $max) {
$max = $items['quantity'];
}
for ($i = $start; $i < $max; $i++) {
$items['items'][] = $feed->get_item($i);
}
//return
if ($items) {
return $items;
} else {
return false;
}
}
示例7: RssFeed
function RssFeed($link)
{
//process rss
$feed_url = $link;
$items_per_feed = 10;
$items_max_age = '-60 days';
$max_age = $items_max_age ? date('Y-m-d H:i:s', strtotime($items_max_age)) : null;
$items = array();
App::import('vendor', 'simplepie/simplepie');
$feed = new SimplePie();
$feed->set_cache_location(CACHE . 'simplepie');
$feed->set_feed_url($feed_url);
$feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
$feed->init();
if ($feed->error() || $feed->feed_url != $feed_url) {
return false;
}
for ($i = 0; $i < $feed->get_item_quantity($items_per_feed); $i++) {
$feeditem = $feed->get_item($i);
# create a NoseRub item out of the feed item
$item = array();
$item['datetime'] = $feeditem->get_date('Y-m-d H:i:s');
if ($max_age && $item['datetime'] < $max_age) {
# we can stop here, as we do not expect any newer items
break;
}
$item['title'] = $feeditem->get_title();
$item['url'] = $feeditem->get_link();
//$item['intro'] = @$intro;
//$item['type'] = @$token;
//$item['username'] = $username;
$items[] = $item;
}
unset($feed);
$items;
foreach ($items as $_item) {
echo '<a href="' . $_item['url'] . '">' . $_item['title'] . '</a><br/>';
}
//end process rss
}
示例8: kingRssOutput
function kingRssOutput($data)
{
$feed = new SimplePie();
$feed->feed_url($data['rss_url']);
$path = explode($_SERVER["SERVER_NAME"], get_bloginfo('wpurl'));
$feed->cache_location($_SERVER['DOCUMENT_ROOT'] . $path[1] . "/wp-content/cache");
if (!empty($data['cache_time'])) {
$feed->max_minutes = $data['cache_time'];
}
if (!empty($data['nosort'])) {
$feed->order_by_date = false;
}
if (!empty($data['stripads'])) {
$feed->strip_ads(1);
}
$feed->bypass_image_hotlink();
$feed->bypass_image_hotlink_page($path[1] . "/index.php");
#if images in feed are protected
$success = $feed->init();
if ($success && $feed->data) {
$output = '';
$replace_title_vars[0] = $feed->get_feed_link();
$replace_title_vars[1] = $feed->get_feed_title();
$replace_title_vars[2] = $feed->get_feed_description();
$replace_title_vars[3] = $data['rss_url'];
$replace_title_vars[4] = get_settings('siteurl') . '/wp-content/plugins/king-framework/images/rss.png';
if ($feed->get_image_exist() == true) {
$replace_title_vars[5] = $feed->get_image_url();
}
$search_title_vars = array('%link%', '%title%', '%descr%', '%rssurl%', '%rssicon%', '%feedimg%');
#parse template placeholders
$output .= str_replace($search_title_vars, $replace_title_vars, $data['titlehtml']);
$max = $feed->get_item_quantity();
if (!empty($data['max_items'])) {
$max = min($data['max_items'], $feed->get_item_quantity());
}
for ($x = 0; $x < $max; $x++) {
$item = $feed->get_item($x);
$replace_vars[0] = stupifyEntities($item->get_title());
$replace_vars[1] = $item->get_permalink();
$replace_vars[2] = $item->get_date($data['showdate']);
$replace_vars[3] = stupifyEntities($item->get_description());
if ($item->get_categories() != false) {
$categories = $item->get_categories();
$replace_vars[4] = implode(" | ", $categories);
}
if ($item->get_author(0) != false) {
$author = $item->get_author(0);
$replace_vars[5] = $author->get_name();
}
# cut article text to length ... do the butcher
if (!empty($data['shortdesc'])) {
$suffix = '...';
$short_desc = trim(str_replace("\n", ' ', str_replace("\r", ' ', strip_tags(stupifyEntities($item->get_description())))));
$desc = substr($short_desc, 0, $data['shortdesc']);
$lastchar = substr($desc, -1, 1);
if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?') {
$suffix = '';
}
$desc .= $suffix;
$replace_vars[3] = $desc;
}
$search_vars = array('%title%', '%link%', '%date%', '%text%', '%category%', '%author%');
#parse template placeholders
$output .= str_replace($search_vars, $replace_vars, $data['rsshtml']);
}
} else {
if (!empty($data['error'])) {
$output = $data['error'];
} else {
if (isset($feed->error)) {
$output = $feed->error;
}
}
}
return $output;
}
示例9: cron
function cron($verbose = false)
{
if ($verbose) {
echo '<p>Starting cron...</p>';
}
global $wpdb;
$options = get_option('proximusmoblog');
if (!is_numeric($options['id'])) {
$options['id'] = 1;
}
// Si l'id du prochain article est invalide, initialisé à 1
if (is_numeric($options['blogid'])) {
// Identifiant valide
// Récupération du flux RSS
require_once ABSPATH . WPINC . '/class-feed.php';
$rss = new SimplePie();
$rss->set_feed_url('http://payandgogeneration.proximus.be/moblogs/rss.cfm?id=' . $options['blogid']);
// Désactiver le cache
$rss->enable_cache(false);
// Désactivation du tri par défaut
$rss->enable_order_by_date(false);
$rss->init();
$rss->handle_content_type();
$maxitems = $rss->get_item_quantity();
// Nombre d'éléments du flux RSS
$rss_items = $rss->get_items(0, $maxitems);
// Tableau des articles récupérés
$hackmin = 0;
// Hack de décalage d'article pour ne pas avoir plusieurs articles publiés en même temps.
for ($i = $maxitems - 1; $i >= 0; --$i) {
$item = $rss->get_item($i);
$guid = $item->get_id();
$guid = substr($guid, strpos($guid, '=') + 1);
$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key = 'proximusMoblog_guid' AND meta_value = '{$guid}'"));
if ($count == 0) {
if ($verbose) {
echo '<li>' . $guid . '</li>';
}
$enclosure = $item->get_enclosure();
$image = $enclosure->get_link();
$image = $this->downloadImage($image, $options['blogid'], $options['id']);
$title = str_replace('[id]', $options['id'], $options['titre']);
$contenu = str_replace('[image]', $image, $options['article']);
$date = date('Y-m-d H:i:s', time() + $hackmin);
// Create post object
$my_post = array();
$my_post['post_title'] = $title;
$my_post['post_content'] = $contenu;
$my_post['post_status'] = 'publish';
$my_post['post_date'] = $date;
if (!empty($options['user'])) {
$my_post['post_author'] = $options['user'];
}
if (!empty($options['categorie'])) {
$my_post['post_category'] = array($options['categorie']);
}
// Insert the post into the database
$postid = wp_insert_post($my_post);
add_post_meta($postid, 'proximusMoblog_guid', $guid);
$options['id']++;
$hackmin += 5;
}
}
update_option('proximusmoblog', $options);
}
// Fin identifiant valide
}
示例10: 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);
}
示例11: SimplePie
function thefrosty_network_feed($attr, $count)
{
global $wpdb;
include_once ABSPATH . WPINC . '/class-simplepie.php';
$feed = new SimplePie();
$feed->set_feed_url($attr);
$feed->enable_cache(true);
$feed->set_cache_duration(60 * 60 * 24 * 7);
$cache_folder = plugin_dir_path(__FILE__) . 'cache';
if (!is_writable($cache_folder)) {
chmod($cache_folder, 0666);
}
$feed->set_cache_location($cache_folder);
$feed->init();
$feed->handle_content_type();
$items = $feed->get_item();
echo '<div class="t' . esc_attr($count) . ' tab-content postbox open feed">';
echo '<ul>';
if (empty($items)) {
echo '<li>No items</li>';
} else {
foreach ($feed->get_items(0, 3) as $item) {
?>
<li>
<a href='<?php
echo esc_url($item->get_permalink());
?>
' title='<?php
esc_attr_e($item->get_description());
?>
'><?php
esc_attr_e($item->get_title());
?>
</a><br />
<span style="font-size:10px; color:#aaa;"><?php
esc_attr_e($item->get_date('F, jS Y | g:i a'));
?>
</span>
</li>
<?php
}
}
echo '</ul>';
echo '</div>';
}
示例12: dirname
/**
* @param string $title
* @return bool
*/
function generate_content(&$title)
{
global $serendipity;
$socialbookmarksID = $this->get_config('socialbookmarksID');
if (empty($socialbookmarksID)) {
return false;
}
$socialbookmarksService = $this->get_config('socialbookmarksService');
if (($title = $this->get_config('sidebarTitle')) == '') {
$title = $socialbookmarksService;
}
$moreLink = $this->get_config('moreLink');
$md5_socialbookmarksID = md5($socialbookmarksID);
$md5_socialbookmarksService = md5($socialbookmarksService);
if ($this->get_config('displayNumber') < 31 && $this->get_config('displayNumber') >= 1) {
$displayNumber = $this->get_config('displayNumber');
} else {
$displayNumber = 30;
}
if ($this->get_config('cacheTime') > 0) {
$cacheTime = $this->get_config('cacheTime') * 3600;
} else {
$cacheTime = 3600 + 1;
}
$gsocialbookmarksURL = $this->feed_types[$socialbookmarksService]['usr_bookmarks_page'];
$gsocialbookmarksFeedURL = $this->feed_types[$socialbookmarksService][$this->get_config('specialFeatures')];
$gsocialbookmarksCacheLoc = $serendipity['serendipityPath'] . '/templates_c/socialbookmarks_';
$parsedCache = $gsocialbookmarksCacheLoc . $md5_socialbookmarksService . '_' . $md5_socialbookmarksID . '.cache';
if (!is_file($parsedCache) || mktime() - filectime($parsedCache) > $cacheTime) {
if (!is_dir($gsocialbookmarksCacheLoc) && !mkdir($gsocialbookmarksCacheLoc, 0775)) {
print 'Try to chmod go+rwx - permissions are wrong.';
}
if ($this->get_config('specialFeatures') != 'usr_js_tagcloud') {
if (file_exists(S9Y_PEAR_PATH . '/simplepie/simplepie.inc')) {
require_once S9Y_PEAR_PATH . '/simplepie/simplepie.inc';
} else {
require_once dirname(__FILE__) . '/simplepie/simplepie.inc';
}
$socialbookmarksFeed = new SimplePie();
$socialbookmarksFeed->set_feed_url(str_replace('%username%', urlencode(utf8_decode(stripslashes($socialbookmarksID))), $gsocialbookmarksFeedURL));
$socialbookmarksFeed->set_cache_location($serendipity['serendipityPath'] . '/templates_c/');
$socialbookmarksFeed->enable_cache(false);
$socialbookmarksFeed->init();
$socialbookmarksFeed->handle_content_type();
if ($socialbookmarksFeed->data) {
$fileHandle = @fopen($parsedCache, 'w');
if ($fileHandle) {
$socialbookmarksContent = '<ul class="serendipity_socialbookmarks_list" style="padding:0.1em;list-style-type:none;font-size:1em;">' . "\r\n";
$max = $socialbookmarksFeed->get_item_quantity($displayNumber);
for ($x = 0; $x < $max; $x++) {
/** @var SimplePie_Item $item */
$item = $socialbookmarksFeed->get_item($x);
$socialbookmarksContent .= '<li class="serendipity_socialbookmarks_item xfolkentry" style="list-style-type:' . ($this->get_config('displayThumbnails') ? 'none' : 'square') . ';list-style-position:inside;">';
$socialbookmarksContent .= '<a href="' . $this->decode($item->get_permalink()) . ' " class="taggedlink" title="' . trim(substr($this->decode(function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($item->get_description())) : htmlspecialchars(strip_tags($item->get_description()), ENT_COMPAT, LANG_CHARSET)), 0, 100)) . '" rel="external">';
if ($this->get_config('displayThumbnails')) {
$socialbookmarksContent .= $this->socialbookmarks_get_thumbnail($item->get_description());
} else {
$socialbookmarksContent .= html_entity_decode($this->decode($item->get_title()), ENT_COMPAT, LANG_CHARSET);
}
$socialbookmarksContent .= '</a>';
if ($this->get_config('displayTags') && class_exists('serendipity_event_freetag')) {
// display tags for each bookmark
$socialbookmarksContent .= $this->socialbookmarks_get_tags($item);
}
$socialbookmarksContent .= '</li>' . "\r\n";
}
$socialbookmarksContent .= '</ul>';
fwrite($fileHandle, $socialbookmarksContent);
fclose($fileHandle);
print $socialbookmarksContent;
} else {
print 'A ' . $this->get_config('socialbookmarksService') . ' error occured! <br />' . 'Error Message: unable to make a socialbookmarks cache file: ' . $parsedCache . '!';
}
} elseif (is_file($parsedCache)) {
print file_get_contents($parsedCache);
} else {
print 'A ' . $this->get_config('socialbookmarksService') . ' error occured! <br />' . 'Error Message: rss failed';
}
} else {
$gsocialbookmarksFeedURL = str_replace('%username%', urlencode(utf8_decode(stripslashes($socialbookmarksID))), $gsocialbookmarksFeedURL);
echo '<script type="text/javascript" src="' . $gsocialbookmarksFeedURL . $this->get_config('additionalParams') . '"></scipt>';
}
} else {
print file_get_contents($parsedCache);
}
if (serendipity_db_bool($moreLink)) {
print '<a href="' . str_replace('%username%', urlencode(utf8_decode(stripslashes($socialbookmarksID))), $gsocialbookmarksURL) . '/">(' . PLUGIN_SOCIALBOOKMARKS_MORELINK . ')</a>';
}
}
示例13: discover_by_url
function discover_by_url($url, $arr = null)
{
require_once 'library/HTML5/Parser.php';
$x = scrape_feed($url);
if (!$x) {
if (!$arr) {
return false;
}
$network = $arr['network'] ? $arr['network'] : 'unknown';
$name = $arr['name'] ? $arr['name'] : 'unknown';
$photo = $arr['photo'] ? $arr['photo'] : '';
$addr = $arr['addr'] ? $arr['addr'] : '';
$guid = $url;
}
$profile = $url;
logger('scrape_feed results: ' . print_r($x, true));
if ($x['feed_atom']) {
$guid = $x['feed_atom'];
}
if ($x['feed_rss']) {
$guid = $x['feed_rss'];
}
if (!$guid) {
return false;
}
// try and discover stuff from the feeed
require_once 'library/simplepie/simplepie.inc';
$feed = new SimplePie();
$level = 0;
$x = z_fetch_url($guid, false, $level, array('novalidate' => true));
if (!$x['success']) {
logger('probe_url: feed fetch failed for ' . $poll);
return false;
}
$xml = $x['body'];
logger('probe_url: fetch feed: ' . $guid . ' returns: ' . $xml, LOGGER_DATA);
logger('probe_url: scrape_feed: headers: ' . $x['header'], LOGGER_DATA);
// Don't try and parse an empty string
$feed->set_raw_data($xml ? $xml : '<?xml version="1.0" encoding="utf-8" ?><xml></xml>');
$feed->init();
if ($feed->error()) {
logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error());
}
$name = unxmlify(trim($feed->get_title()));
$photo = $feed->get_image_url();
$author = $feed->get_author();
if ($author) {
if (!$name) {
$name = unxmlify(trim($author->get_name()));
}
if (!$name) {
$name = trim(unxmlify($author->get_email()));
if (strpos($name, '@') !== false) {
$name = substr($name, 0, strpos($name, '@'));
}
}
if (!$profile && $author->get_link()) {
$profile = trim(unxmlify($author->get_link()));
}
if (!$photo) {
$rawtags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
if ($rawtags) {
$elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') {
$photo = $elems['link'][0]['attribs']['']['href'];
}
}
}
} else {
$item = $feed->get_item(0);
if ($item) {
$author = $item->get_author();
if ($author) {
if (!$name) {
$name = trim(unxmlify($author->get_name()));
if (!$name) {
$name = trim(unxmlify($author->get_email()));
}
if (strpos($name, '@') !== false) {
$name = substr($name, 0, strpos($name, '@'));
}
}
if (!$profile && $author->get_link()) {
$profile = trim(unxmlify($author->get_link()));
}
}
if (!$photo) {
$rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/', 'thumbnail');
if ($rawmedia && $rawmedia[0]['attribs']['']['url']) {
$photo = unxmlify($rawmedia[0]['attribs']['']['url']);
}
}
if (!$photo) {
$rawtags = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
if ($rawtags) {
$elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') {
$photo = $elems['link'][0]['attribs']['']['href'];
}
}
//.........这里部分代码省略.........
示例14: probe_url
//.........这里部分代码省略.........
$a = get_app();
logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), LOGGER_DATA);
$feed->set_raw_data($xml);
$feed->init();
if ($feed->error()) {
logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error());
}
if (!x($vcard, 'photo')) {
$vcard['photo'] = $feed->get_image_url();
}
$author = $feed->get_author();
if ($author) {
$vcard['fn'] = unxmlify(trim($author->get_name()));
if (!$vcard['fn']) {
$vcard['fn'] = trim(unxmlify($author->get_email()));
}
if (strpos($vcard['fn'], '@') !== false) {
$vcard['fn'] = substr($vcard['fn'], 0, strpos($vcard['fn'], '@'));
}
$email = unxmlify($author->get_email());
if (!$profile && $author->get_link()) {
$profile = trim(unxmlify($author->get_link()));
}
if (!$vcard['photo']) {
$rawtags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
if ($rawtags) {
$elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') {
$vcard['photo'] = $elems['link'][0]['attribs']['']['href'];
}
}
}
} else {
$item = $feed->get_item(0);
if ($item) {
$author = $item->get_author();
if ($author) {
$vcard['fn'] = trim(unxmlify($author->get_name()));
if (!$vcard['fn']) {
$vcard['fn'] = trim(unxmlify($author->get_email()));
}
if (strpos($vcard['fn'], '@') !== false) {
$vcard['fn'] = substr($vcard['fn'], 0, strpos($vcard['fn'], '@'));
}
$email = unxmlify($author->get_email());
if (!$profile && $author->get_link()) {
$profile = trim(unxmlify($author->get_link()));
}
}
if (!$vcard['photo']) {
$rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/', 'thumbnail');
if ($rawmedia && $rawmedia[0]['attribs']['']['url']) {
$vcard['photo'] = unxmlify($rawmedia[0]['attribs']['']['url']);
}
}
if (!$vcard['photo']) {
$rawtags = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
if ($rawtags) {
$elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') {
$vcard['photo'] = $elems['link'][0]['attribs']['']['href'];
}
}
}
}
}
示例15: SimplePie
<div class="nav_head">
<h3>Project Status</h3>
</div>
<div class="nav_main">
<ul>
<!-- <li>Status: 93%</li> -->
<li>Last release:<br/>
<?php
$projfiles = new SimplePie();
$projfiles->enable_cache(false);
$projfiles->set_feed_url('http://sourceforge.net/export/rss2_projfiles.php?group_id=136478');
$projfiles->init();
$projfiles->handle_content_type();
if ($projfiles->data) {
$item = $projfiles->get_item(0);
list($version, $head) = split("released", $item->get_title());
//echo $version;
// if a part of the Version Sting overlaps the "Project Status"
// Box, the whole site looks bad with IE.
$token = strtok($version, " ");
while ($token != false) {
if (strlen($token) >= 20) {
echo chunk_split($token, 20, "<br/>");
} else {
echo "{$token} ";
}
$token = strtok(" ");
}
}
?>