当前位置: 首页>>代码示例>>PHP>>正文


PHP SimplePie::subscribe_url方法代码示例

本文整理汇总了PHP中SimplePie::subscribe_url方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::subscribe_url方法的具体用法?PHP SimplePie::subscribe_url怎么用?PHP SimplePie::subscribe_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimplePie的用法示例。


在下文中一共展示了SimplePie::subscribe_url方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 /**
  * Add a new feed to the database
  *
  * Adds the specified feed name and URL to the database. 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
  *
  * @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
  * @return bool True if succeeded, false if failed
  */
 public function add($url, $name = '', $cat = 'default')
 {
     if (empty($url)) {
         throw new Exception(_r("Couldn't add feed: No feed URL supplied"), Errors::get_code('admin.feeds.no_url'));
     }
     if (!preg_match('#https|http|feed#', $url)) {
         if (strpos($url, '://')) {
             throw new Exception(_r('Unsupported URL protocol'), Errors::get_code('admin.feeds.protocol_error'));
         }
         $url = 'http://' . $url;
     }
     require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc';
     $feed_info = new SimplePie();
     $feed_info->set_useragent(LILINA_USERAGENT . ' SimplePie/' . SIMPLEPIE_BUILD);
     $feed_info->set_stupidly_fast(true);
     $feed_info->set_cache_location(get_option('cachedir'));
     $feed_info->set_favicon_handler(get_option('baseurl') . '/lilina-favicon.php');
     $feed_info->set_feed_url($url);
     $feed_info->init();
     $feed_error = $feed_info->error();
     $feed_url = $feed_info->subscribe_url();
     if (!empty($feed_error)) {
         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();
     }
     $id = sha1($feed_url);
     $this->feeds[$id] = array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'id' => $id, 'name' => $name, 'cat' => $cat, 'icon' => $feed_info->get_favicon());
     $this->feeds[$id] = apply_filters('feed-create', $this->feeds[$id], $url);
     $this->save();
     return array('msg' => sprintf(_r('Added feed "%1$s"'), $name), 'id' => $id);
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:49,代码来源:class-feeds.php

示例2: add

 /**
  * Add a new feed to the database
  *
  * Adds the specified feed name and URL to the database. 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
  *
  * @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
  * @return bool True if succeeded, false if failed
  */
 public function add($url, $name = '', $cat = 'default')
 {
     if (empty($url)) {
         throw new Exception(_r("Couldn't add feed: No feed URL supplied"), Errors::get_code('admin.feeds.no_url'));
     }
     if (!preg_match('#https|http|feed#', $url)) {
         if (strpos($url, '://')) {
             throw new Exception(_r('Unsupported URL protocol'), Errors::get_code('admin.feeds.protocol_error'));
         }
         $url = 'http://' . $url;
     }
     $reporting = error_reporting();
     error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR);
     require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
     // Need this for LILINA_USERAGENT
     class_exists('HTTPRequest');
     require_once LILINA_INCPATH . '/core/class-httprequest.php';
     $feed_info = new SimplePie();
     $feed_info->set_useragent(LILINA_USERAGENT . ' SimplePie/' . SIMPLEPIE_BUILD);
     $feed_info->set_stupidly_fast(true);
     $feed_info->set_cache_location(get_option('cachedir'));
     $feed_info->set_feed_url($url);
     $feed_info->init();
     $feed_error = $feed_info->error();
     $feed_url = $feed_info->subscribe_url();
     if (!empty($feed_error)) {
         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();
     }
     $id = sha1($feed_url);
     // Do a naive check to see if the feed already exists
     if ($this->get($id) !== false) {
         throw new Exception(_r("Couldn't add feed: you have already added that feed"), Errors::get_code('admin.feeds.feed_already_exists'));
     }
     $this->feeds[$id] = array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'id' => $id, 'name' => $name, 'cat' => $cat, 'icon' => self::discover_favicon($feed_info, $id));
     $this->feeds[$id] = apply_filters('feed-create', $this->feeds[$id], $url, $feed_info);
     $this->save();
     error_reporting($reporting);
     return array('msg' => sprintf(_r('Added feed "%1$s"'), $name), 'id' => $id);
 }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:58,代码来源:class-feeds.php

示例3: 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);
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:46,代码来源:feed-functions.php

示例4:

		</div>
	</div>
</div>

<div id="site">

	<div id="content">

		<div class="chunk">
			<form action="" method="get" name="sp_form" id="sp_form">
				<div id="sp_input">


					<!-- If a feed has already been passed through the form, then make sure that the URL remains in the form field. -->
					<p><input type="text" name="feed" value="<?php 
if ($feed->subscribe_url()) {
    echo $feed->subscribe_url();
}
?>
" class="text" id="feed_input" />&nbsp;<input type="submit" value="Read" class="button" /></p>


				</div>
			</form>


			<?php 
// Check to see if there are more than zero errors (i.e. if there are any errors at all)
if ($feed->error()) {
    // If so, start a <div> element with a classname so we can style it.
    echo '<div class="sp_errors">' . "\r\n";
开发者ID:himanshu12k,项目名称:ce-www,代码行数:31,代码来源:index.php

示例5: htmlspecialchars

		</div>
	</div>
</div>

<div id="site">

	<div id="content">

		<div class="chunk">
			<form action="" method="get" name="sp_form" id="sp_form">
				<div id="sp_input">


					<!-- If a feed has already been passed through the form, then make sure that the URL remains in the form field. -->
					<p><input type="text" name="feed" value="<?php 
if ($feed->subscribe_url()) {
    echo htmlspecialchars($feed->subscribe_url());
}
?>
" class="text" id="feed_input" />&nbsp;<input type="submit" value="Read" class="button" /></p>


				</div>
			</form>


			<?php 
// Check to see if there are more than zero errors (i.e. if there are any errors at all)
if ($feed->error()) {
    // If so, start a <div> element with a classname so we can style it.
    echo '<div class="sp_errors">' . "\r\n";
开发者ID:simonescu,项目名称:mashupkeyword,代码行数:31,代码来源:index.php

示例6: items


//.........这里部分代码省略.........
                                         $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
                                     }
                                 }
                             }
                             $this->db->set('fed_nextcrawl', $nextcrawl);
                         }
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } catch (Facebook\Exceptions\FacebookResponseException $e) {
                         $errors++;
                         $this->db->set('fed_lasterror', 'Graph returned an error: ' . $e->getMessage());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         $errors++;
                         $this->db->set('fed_lasterror', 'Facebook SDK returned an error: ' . $e->getMessage());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     }
                 } else {
                     $sp_feed = new SimplePie();
                     $sp_feed->set_feed_url(convert_to_ascii($fed->fed_link));
                     $sp_feed->enable_cache(false);
                     $sp_feed->set_timeout(5);
                     $sp_feed->force_feed(true);
                     $sp_feed->init();
                     $sp_feed->handle_content_type();
                     if ($sp_feed->error()) {
                         $errors++;
                         $this->db->set('fed_lasterror', $sp_feed->error());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } else {
                         $this->readerself_library->crawl_items($fed->fed_id, $sp_feed->get_items());
                         $lastitem = $this->db->query('SELECT itm.itm_datecreated FROM ' . $this->db->dbprefix('items') . ' AS itm WHERE itm.fed_id = ? GROUP BY itm.itm_id ORDER BY itm.itm_id DESC LIMIT 0,1', array($fed->fed_id))->row();
                         $parse_url = parse_url($sp_feed->get_link());
                         $this->db->set('fed_title', $sp_feed->get_title());
                         $this->db->set('fed_url', $sp_feed->get_link());
                         $this->db->set('fed_link', $sp_feed->subscribe_url());
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         if ($sp_feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
                             $this->db->set('fed_type', 'rss');
                         } else {
                             if ($sp_feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
                                 $this->db->set('fed_type', 'atom');
                             }
                         }
                         if ($sp_feed->get_image_url()) {
                             $this->db->set('fed_image', $sp_feed->get_image_url());
                         }
                         $this->db->set('fed_description', $sp_feed->get_description());
                         $this->db->set('fed_lasterror', '');
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         if ($lastitem) {
                             $nextcrawl = '';
                             //older than 96 hours, next crawl in 12 hours
                             if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24 * 96)) {
                                 $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 12);
                                 //older than 48 hours, next crawl in 6 hours
                             } else {
                                 if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 48)) {
                                     $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 6);
                                     //older than 24 hours, next crawl in 3 hours
                                 } else {
                                     if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24)) {
                                         $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
                                     }
                                 }
                             }
                             $this->db->set('fed_nextcrawl', $nextcrawl);
                         }
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     }
                     $sp_feed->__destruct();
                     unset($sp_feed);
                 }
             }
             $this->db->set('crr_time', microtime(1) - $microtime_start);
             if (function_exists('memory_get_peak_usage')) {
                 $this->db->set('crr_memory', memory_get_peak_usage());
             }
             $this->db->set('crr_feeds', $query->num_rows());
             if ($errors > 0) {
                 $this->db->set('crr_errors', $errors);
             }
             $this->db->set('crr_datecreated', date('Y-m-d H:i:s'));
             $this->db->insert('crawler');
             if ($this->db->dbdriver == 'mysqli') {
                 $this->db->query('OPTIMIZE TABLE categories, connections, enclosures, favorites, feeds, folders, history, items, members, share, subscriptions');
             }
         }
     }
     $this->readerself_library->set_content($content);
 }
开发者ID:esironal,项目名称:readerself,代码行数:101,代码来源:refresh.php

示例7: create


//.........这里部分代码省略.........
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=feed{created_time,id,message,story,full_picture,place,type,status_type,link}');
                         $response = $fb->getClient()->sendRequest($request);
                         $posts = $response->getDecodedBody();
                         $this->readerself_library->crawl_items_facebook($fed_id, $posts['feed']['data']);
                         redirect(base_url() . 'subscriptions/read/' . $sub_id);
                     } catch (Facebook\Exceptions\FacebookResponseException $e) {
                         $data['error'] = 'Graph returned an error: ' . $e->getMessage();
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
                     }
                 } else {
                     include_once 'thirdparty/simplepie/autoloader.php';
                     include_once 'thirdparty/simplepie/idn/idna_convert.class.php';
                     $sp_feed = new SimplePie();
                     $sp_feed->set_feed_url(convert_to_ascii($this->input->post('url')));
                     $sp_feed->enable_cache(false);
                     $sp_feed->set_timeout(60);
                     $sp_feed->force_feed(true);
                     $sp_feed->init();
                     $sp_feed->handle_content_type();
                     if ($sp_feed->error()) {
                         $data['error'] = $sp_feed->error();
                     } else {
                         $parse_url = parse_url($sp_feed->get_link());
                         $this->db->set('fed_title', $sp_feed->get_title());
                         $this->db->set('fed_url', $sp_feed->get_link());
                         $this->db->set('fed_description', $sp_feed->get_description());
                         $this->db->set('fed_link', $sp_feed->subscribe_url());
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $data['sub_id'] = $sub_id;
                         $data['fed_title'] = $sp_feed->get_title();
                         $this->readerself_library->crawl_items($fed_id, $sp_feed->get_items());
                     }
                     $sp_feed->__destruct();
                     unset($sp_feed);
                 }
             }
         } else {
             $fed = $query->row();
             if (!$fed->sub_id) {
                 $this->db->set('mbr_id', $this->member->mbr_id);
                 $this->db->set('fed_id', $fed->fed_id);
                 if ($this->config->item('folders')) {
                     if ($folder) {
                         $this->db->set('flr_id', $folder);
                     }
                 }
                 $this->db->set('sub_priority', $this->input->post('priority'));
                 $this->db->set('sub_direction', $this->input->post('direction'));
                 $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                 $this->db->insert('subscriptions');
                 $sub_id = $this->db->insert_id();
             } else {
                 $sub_id = $fed->sub_id;
             }
             $data['sub_id'] = $sub_id;
             $data['fed_title'] = $fed->fed_title;
         }
         if ($data['error']) {
             $content = $this->load->view('subscriptions_create', $data, TRUE);
         } else {
             redirect(base_url() . 'subscriptions/read/' . $sub_id);
         }
     }
     $this->readerself_library->set_content($content);
 }
开发者ID:slowmotion,项目名称:readerself,代码行数:101,代码来源:Subscriptions.php

示例8: empty

form#sp_form input.text {
	width:85%;
}
</style>

</head>

<body>
	<h1><?php 
echo empty($_GET['feed']) ? 'SimplePie' : 'SimplePie: ' . $feed->get_title();
?>
</h1>

	<form action="" method="get" name="sp_form" id="sp_form">
		<p><input type="text" name="feed" value="<?php 
echo $feed->subscribe_url() ? htmlspecialchars($feed->subscribe_url()) : 'http://';
?>
" class="text" id="feed_input" />&nbsp;<input type="submit" value="Read" class="button" /></p>
	</form>

	<div id="sp_results">
		<?php 
if ($feed->data) {
    ?>
			<?php 
    $items = $feed->get_items();
    ?>
			<p align="center"><span style="background-color:#ffc;">Displaying <?php 
    echo $feed->get_item_quantity();
    ?>
 most recent entries.</span></p>
开发者ID:Gninety,项目名称:Microweber,代码行数:31,代码来源:minimalistic.php

示例9: SimplePieWP


//.........这里部分代码省略.........
        $tmpl = str_replace('{FEED_IMAGE_WIDTH}', '', $tmpl);
    }
    // FEED_LANGUAGE
    if ($language = $feed->get_language()) {
        $tmpl = str_replace('{FEED_LANGUAGE}', SimplePie_WordPress::post_process('FEED_LANGUAGE', $language), $tmpl);
    } else {
        $tmpl = str_replace('{FEED_LANGUAGE}', '', $tmpl);
    }
    // FEED_LATITUDE
    if ($latitude = $feed->get_latitude()) {
        $tmpl = str_replace('{FEED_LATITUDE}', SimplePie_WordPress::post_process('FEED_LATITUDE', $latitude), $tmpl);
    } else {
        $tmpl = str_replace('{FEED_LATITUDE}', '', $tmpl);
    }
    // FEED_LONGITUDE
    if ($longitude = $feed->get_longitude()) {
        $tmpl = str_replace('{FEED_LONGITUDE}', SimplePie_WordPress::post_process('FEED_LONGITUDE', $longitude), $tmpl);
    } else {
        $tmpl = str_replace('{FEED_LONGITUDE}', '', $tmpl);
    }
    // FEED_PERMALINK
    if ($permalink = $feed->get_permalink()) {
        $tmpl = str_replace('{FEED_PERMALINK}', SimplePie_WordPress::post_process('FEED_PERMALINK', $permalink), $tmpl);
    } else {
        $tmpl = str_replace('{FEED_PERMALINK}', '', $tmpl);
    }
    // FEED_TITLE
    if ($title = $feed->get_title()) {
        $tmpl = str_replace('{FEED_TITLE}', SimplePie_WordPress::post_process('FEED_TITLE', $title), $tmpl);
    } else {
        $tmpl = str_replace('{FEED_TITLE}', '', $tmpl);
    }
    // SUBSCRIBE_URL
    if ($subscribe_url = $feed->subscribe_url()) {
        $tmpl = str_replace('{SUBSCRIBE_URL}', SimplePie_WordPress::post_process('SUBSCRIBE_URL', $subscribe_url), $tmpl);
    } else {
        $tmpl = str_replace('{SUBSCRIBE_URL}', '', $tmpl);
    }
    // TRUNCATE_FEED_DESCRIPTION
    if ($description = $feed->get_description()) {
        $tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_DESCRIPTION', $description), $truncate_feed_description), $tmpl);
    } else {
        $tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', '', $tmpl);
    }
    // TRUNCATE_FEED_TITLE
    if ($title = $feed->get_title()) {
        $tmpl = str_replace('{TRUNCATE_FEED_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_TITLE', $title), $truncate_feed_title), $tmpl);
    } else {
        $tmpl = str_replace('{TRUNCATE_FEED_TITLE}', '', $tmpl);
    }
    /**************************************************************************************************************/
    // ITEMS
    // Separate out the pre-item template
    $tmpl = explode('{ITEM_LOOP_BEGIN}', $tmpl);
    $pre_tmpl = $tmpl[0];
    // Separate out the item template
    $tmpl = explode('{ITEM_LOOP_END}', $tmpl[1]);
    $item_tmpl = $tmpl[0];
    // Separate out the post-item template
    $post_tmpl = $tmpl[1];
    // Clear out the variable
    unset($tmpl);
    // Start putting the output string together.
    $tmpl = $pre_tmpl;
    // Loop through all of the items that we're supposed to.
    foreach ($feed->get_items(0, $items) as $item) {
开发者ID:simplepie,项目名称:wordpress,代码行数:67,代码来源:simplepie_wordpress_2.php

示例10: die

 /**
  * called by do_ajax())
  * takes action when ajax request is made with URL from the comment form
  * send back 1 or 10 last posts depending on rules
  */
 function fetch_feed()
 {
     // check nonce
     //debugbreak();
     $options = $this->get_options();
     if (isset($options['use_nonce'])) {
         $checknonce = check_ajax_referer('fetch', false, false);
         if (!$checknonce) {
             die(' error! not authorized ' . strip_tags($_REQUEST['_ajax_nonce']));
         }
     }
     if (!$_POST['url']) {
         die('no url');
     }
     if (!defined('DOING_AJAX')) {
         define('DOING_AJAX', true);
     }
     // try to prevent deprecated notices
     @ini_set('display_errors', 0);
     @error_reporting(0);
     include_once ABSPATH . WPINC . '/class-simplepie.php';
     $num = 1;
     $url = esc_url($_POST['url']);
     $orig_url = $url;
     // add trailing slash (can help with some blogs)
     if (!strpos($url, '?')) {
         $url = trailingslashit($url);
     }
     // fetch 10 last posts?
     if (is_user_logged_in() && $options['whogets'] == 'registered' || !is_user_logged_in() && $options['whogets'] == 'everybody') {
         $num = 10;
     } elseif ($options['whogets'] == 'everybody') {
         $num = 10;
     } elseif (current_user_can('manage_options')) {
         $num = 10;
     }
     // check if request is for the blog we're on
     if (strstr($url, home_url())) {
         //DebugBreak();
         $posts = get_posts(array('numberposts' => 10));
         $return = array();
         $error = '';
         if ($posts) {
             foreach ($posts as $post) {
                 $return[] = array('type' => 'blog', 'title' => htmlspecialchars_decode(strip_tags($post->post_title)), 'link' => get_permalink($post->ID), 'p' => 'u');
             }
         } else {
             $error = __('Could not get posts for home blog', $this->plugin_domain);
         }
         // check for admin only notices to add
         $canreg = get_option('users_can_register');
         $whogets = $options['whogets'];
         if (!$canreg && $whogets == 'registered') {
             $return[] = array('type' => 'message', 'title' => __('Warning! You have set to show 10 posts for registered users but you have not enabled user registrations on your site. You should change the operational settings in the CommentLuv settings page to show 10 posts for everyone or enable user registrations', $this->plugin_domain), 'link' => '');
         }
         $response = json_encode(array('error' => $error, 'items' => $return));
         header("Content-Type: application/json");
         echo $response;
         exit;
     }
     // get simple pie ready
     $rss = new SimplePie();
     if (!$rss) {
         die(' error! no simplepie');
     }
     $rss->set_useragent('Commentluv /' . $this->version . ' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502');
     $rss->set_feed_url(add_query_arg(array('commentluv' => 'true'), $url));
     $rss->enable_cache(FALSE);
     // fetch the feed
     $rss->init();
     $su = $rss->subscribe_url();
     $ferror = $rss->error();
     // try a fall back and add /?feed=rss2 to the end of url if the found subscribe url hasn't already got it
     // also try known blogspot feed location if this is a blogspot url
     if ($ferror || strstr($ferror, 'could not be found') && !strstr($su, 'feed')) {
         unset($rss);
         $rss = new SimplePie();
         $rss->set_useragent('Commentluv /' . $this->version . ' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502');
         $rss->enable_cache(FALSE);
         // construct alternate feed url
         if (strstr($url, 'blogspot')) {
             $url = trailingslashit($url) . 'feeds/posts/default/';
         } else {
             $url = add_query_arg(array('feed' => 'atom'), $url);
         }
         $rss->set_feed_url($url);
         $rss->init();
         $ferror = $rss->error();
         if ($ferror || stripos($ferror, 'invalid')) {
             $suburl = $rss->subscribe_url() ? $rss->subscribe_url() : $orig_url;
             unset($rss);
             $rss = new SimplePie();
             $rss->set_useragent('Commentluv /' . $this->version . ' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502');
             $rss->enable_cache(FALSE);
             $rss->set_feed_url($orig_url);
//.........这里部分代码省略.........
开发者ID:lykeven,项目名称:graspzhihu,代码行数:101,代码来源:commentluv.php


注:本文中的SimplePie::subscribe_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。