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


PHP SimplePie::set_url_replacements方法代码示例

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


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

示例1: SimplePie

 $http->userAgentDefault = HumbleHttpAgent::UA_PHP;
 // configure SimplePie HTTP extension class to use our HumbleHttpAgent instance
 SimplePie_HumbleHttpAgent::set_agent($http);
 $feed = new SimplePie();
 // some feeds use the text/html content type - force_feed tells SimplePie to process anyway
 $feed->force_feed(true);
 $feed->set_file_class('SimplePie_HumbleHttpAgent');
 //$feed->set_feed_url($url); // colons appearing in the URL's path get encoded
 $feed->feed_url = $url;
 $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
 $feed->set_timeout(20);
 $feed->enable_cache(false);
 $feed->set_stupidly_fast(true);
 $feed->enable_order_by_date(false);
 // we don't want to do anything to the feed
 $feed->set_url_replacements(array());
 // initialise the feed
 // the @ suppresses notices which on some servers causes a 500 internal server error
 $result = @$feed->init();
 //$feed->handle_content_type();
 //$feed->get_title();
 if ($result && (!is_array($feed->data) || count($feed->data) == 0)) {
     die('Sorry, no feed items found');
 }
 // from now on, we'll identify ourselves as a browser
 $http->userAgentDefault = HumbleHttpAgent::UA_BROWSER;
 // Enable caching for multiple downloader
 if (class_exists('HttpRequestPool')) {
     $http->method = $http::METHOD_REQUEST_POOL;
 } elseif (function_exists('curl_multi_init')) {
     $http->method = $http::METHOD_CURL_MULTI;
开发者ID:yangchenghu,项目名称:full-text-rss,代码行数:31,代码来源:makefulltextfeed.php

示例2: customSimplePie

function customSimplePie()
{
    $simplePie = new SimplePie();
    $simplePie->set_useragent(Minz_Translate::t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
    $simplePie->set_cache_location(CACHE_PATH);
    $simplePie->set_cache_duration(1500);
    $simplePie->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'link', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'plaintext', 'script', 'style'));
    $simplePie->strip_attributes(array_merge($simplePie->strip_attributes, array('autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless')));
    $simplePie->add_attributes(array('img' => array('lazyload' => ''), 'audio' => array('preload' => 'none'), 'iframe' => array('postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('postpone' => '', 'preload' => 'none')));
    $simplePie->set_url_replacements(array('a' => 'href', 'area' => 'href', 'audio' => 'src', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'iframe' => 'src', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite', 'source' => 'src', 'track' => 'src', 'video' => array('poster', 'src')));
    return $simplePie;
}
开发者ID:woshilapin,项目名称:FreshRSS,代码行数:12,代码来源:lib_rss.php

示例3: get_items_feed

 public static function get_items_feed($url, $params = null)
 {
     $feed = new SimplePie();
     $mode = isset($params->mode) ? $params->mode : 0;
     if ($mode == 0) {
         $feed->set_feed_url($url);
     } else {
         $html = ogbFile::get_curl($url);
         $feed->set_raw_data($html);
     }
     $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
     $feed->set_timeout(20);
     $feed->enable_cache(false);
     $feed->set_stupidly_fast(true);
     $feed->enable_order_by_date(false);
     // we don't want to do anything to the feed
     $feed->set_url_replacements(array());
     $feed->force_feed(true);
     $result = $feed->init();
     if (isset($_GET['x'])) {
         echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n";
         echo "<p>URL: [{$url}]</p>";
         echo "<p>Error: [{$feed->error}]</p>";
     }
     $items = $feed->get_items();
     $c_items = count($items);
     if ($c_items == 0) {
         echo "<p>Error: [{$feed->error}]</p>";
         return array();
     }
     for ($i = 0; $i < count($items); $i++) {
         $row = new stdclass();
         $row->title = $items[$i]->get_title();
         # the title for the post
         $row->link = $items[$i]->get_link();
         # a single link for the post
         $row->description = $items[$i]->get_description();
         # the content of the post (prefers summaries)
         $row->author = $items[$i]->get_author();
         # a single author for the post
         $row->date = $items[$i]->get_date('Y-m-d H:i:s');
         $row->enclosures = $items[$i]->get_enclosures();
         $rows[] = $row;
     }
     return $rows;
 }
开发者ID:kosir,项目名称:wp-pipes,代码行数:46,代码来源:rss.php

示例4: get_default_item

 public static function get_default_item()
 {
     $id = filter_input(INPUT_POST, 'id');
     $value_default = filter_input(INPUT_POST, 'val_default');
     if ($value_default == '') {
         return 'Do nothing!';
     }
     $feed = new SimplePie();
     $path = OGRAB_EDATA . 'item-' . $id . DS . 'row-default.dat';
     $feed->set_feed_url($value_default);
     $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
     $feed->set_timeout(20);
     $feed->enable_cache(false);
     $feed->set_stupidly_fast(true);
     $feed->enable_order_by_date(false);
     // we don't want to do anything to the feed
     $feed->set_url_replacements(array());
     $result = $feed->init();
     if (isset($_GET['x'])) {
         echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n";
         echo "<p>URL: [{$value_default}]</p>";
         echo "<p>Error: [{$feed->error}]</p>";
     }
     $items = $feed->get_items();
     $c_items = count($items);
     if ($c_items == 0) {
         echo "<p>Error: [{$feed->error}]</p>";
         return array();
     }
     $row = new stdclass();
     $row->title = html_entity_decode($items[0]->get_title(), ENT_QUOTES, 'UTF-8');
     # the title for the post
     $row->link = $items[0]->get_link();
     # a single link for the post
     $row->description = $items[0]->get_description();
     # the content of the post (prefers summaries)
     $row->author = $items[0]->get_author();
     # a single author for the post
     $row->date = $items[0]->get_date('Y-m-d H:i:s');
     $row->enclosures = $items[0]->get_enclosures();
     if (!is_file($path)) {
         $source = new stdClass();
     } else {
         $source = ogb_common::get_default_data('', $id);
     }
     $source->so = $row;
     $cache = serialize($source);
     if (isset($_GET['x2'])) {
         //echo "\n\n<br /><i><b>File:</b>".__FILE__.' <b>Line:</b>'.__LINE__."</i><br />\n\n";
         echo '<br>Path: ' . $path;
     }
     ogbFile::write($path, $cache);
     exit;
 }
开发者ID:kosir,项目名称:wp-pipes,代码行数:54,代码来源:rssreader.php

示例5: feeds

function feeds($id)
{
    $app = Slim::getInstance();
    $app->view()->setData('id_feed_atual', $id);
    if (!is_numeric($id)) {
        $errors = "A página não existe";
        $app->flash('errors', $errors);
        $app->redirect(URL_BASE . '/');
        exit;
    }
    $feeds = new Crud();
    $feeds->setTabela('feeds');
    $user = $app->view()->getData('user');
    $l = $feeds->consultar(array('nome', 'url', 'publico', 'id_categoria'), 'id_user =' . $user['id'] . ' AND id =' . $id)->fetchAll(PDO::FETCH_ASSOC);
    if (count($l) > 0) {
        $read = new SimplePie();
        $read->enable_cache(false);
        $read->set_feed_url($l[0]['url']);
        $read->set_url_replacements(array('a' => 'href', 'img' => 'src'));
        $read->strip_htmltags(array('a'));
        $read->init();
        $read->handle_content_type();
        $app->render('home.php', array('rss' => $read->get_items(), 'nome' => $l[0]['nome']));
    } else {
        echo "Esta página não existe";
    }
}
开发者ID:romulo1984,项目名称:dehbora,代码行数:27,代码来源:routes.php


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