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


PHP SimplePie::feed_url方法代码示例

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


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

示例1: parse

 function parse($caching = true)
 {
     $feed = new SimplePie();
     $feed->feed_url($this->uri);
     $feed->cache_location(SIMPLEPIE_CACHE_DIR);
     $feed->enable_caching($caching);
     // parse
     $parse_result = @$feed->init();
     if ($parse_result === false) {
         trigger_error("FeedParser::parse(): Failed to parse feed. uri: {$this->uri}", E_USER_NOTICE);
         return false;
     }
     $feed->handle_content_type();
     $link = $feed->get_feed_link();
     $channel = array('title' => $feed->get_feed_title(), 'link' => $link, 'uri' => $this->uri, 'last_modified' => SimplePie_Sanitize::parse_date($feed->data['last-modified']), 'description' => $feed->get_feed_description());
     // url
     $url = new Net_URL($feed->get_feed_link());
     $items = array();
     $feed_items = @$feed->get_items();
     if (is_array($feed_items)) {
         foreach ($feed_items as $item) {
             // category
             $categories = $item->get_category();
             if ($categories != '') {
                 $category = split(" ", $categories);
                 $category = array_trim($category);
             } else {
                 $category = '';
             }
             // author
             $author = '';
             if (is_array($authors = $item->get_authors())) {
                 $men = array();
                 foreach ($item->get_authors() as $man) {
                     $men[] = $man->get_name();
                 }
                 $author = join(', ', $men);
             }
             // description
             $description = $item->get_description();
             if (empty($description)) {
                 $description = '';
             }
             $items[] = array('title' => $item->get_title(), 'uri' => $item->get_permalink(), 'description' => $description, 'date' => $item->get_date('U'), 'author' => $author, 'category' => $category);
         }
     }
     $this->data = array('channel' => $channel, 'items' => $items);
     $this->parser =& $feed;
     unset($feed);
     return true;
 }
开发者ID:komagata,项目名称:plnet,代码行数:51,代码来源:FeedParser.php

示例2: 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;
}
开发者ID:schorsch,项目名称:wordpress-king,代码行数:77,代码来源:king-rss.php

示例3: explode

<?php

// Start counting time for the page load
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];
// Include SimplePie
// Located in the parent directory
include_once $c["path"] . 'plugin/feedreader/simplepie.inc';
include_once $c["path"] . 'plugin/feedreader/idn/idna_convert.class.php';
// Create a new instance of the SimplePie object
$feed = new SimplePie();
// Set these Configuration Options
$feed->strip_ads(true);
$feed->feed_url($url);
// Allow us to change the input encoding from the URL string if we want to. (optional)
if (!empty($_GET['input'])) {
    $feed->input_encoding($_GET['input']);
}
// Allow us to snap into IHBB mode.
if (!empty($_GET['image'])) {
    $feed->bypass_image_hotlink('i');
    $feed->bypass_image_hotlink_page('./ihbb.php');
}
// Initialize the whole SimplePie object.  Read the feed, process it, parse it, cache it, and
// all that other good stuff.  The feed's information will not be available to SimplePie before
// this is called.
$feed->init();
// We'll make sure that the right content type and character encoding gets set automatically.
// This function will grab the proper character encoding, as well as set the content type to text/html.
$feed->handle_content_type();
// When we end our PHP block, we want to make sure our DOCTYPE is on the top line to make
开发者ID:BackupTheBerlios,项目名称:nxwcms-svn,代码行数:31,代码来源:index.php

示例4: dirname

<?php

error_reporting(E_ALL);
require_once dirname(dirname(__FILE__)) . '/webapp/config.php';
require_once 'simplepie.inc';
$feed = new SimplePie();
$feed->feed_url($_SERVER['argv'][1]);
$feed->enable_caching(false);
$res = $feed->init();
echo "res: {$res}\n";
print_r($feed);
foreach ($feed->get_items() as $item) {
    print_r($item);
    echo "Date: " . $item->get_date() . "\n";
}
开发者ID:komagata,项目名称:plnet,代码行数:15,代码来源:simplepie.php

示例5: callbackAddRssFeeds

 function callbackAddRssFeeds($hookName, $args)
 {
     if ($this->getEnabled()) {
         $current = $args[0];
         $output =& $args[1];
         $journal =& Request::getJournal();
         $journalId = $journal->getJournalId();
         $templateMgr =& TemplateManager::getManager();
         $this->import('SimplePie');
         $urls = $this->getSetting($journalId, 'urls');
         $months = $this->getSetting($journalId, 'months');
         $aggregate = $this->getSetting($journalId, 'aggregate');
         $feeds = array();
         foreach ($urls as $feedInfo) {
             $webSafe = array();
             foreach (explode(":", $feedInfo['pageName']) as $pageName) {
                 $webSafe[] = ContentManager::websafe($pageName);
             }
             $webSafe = implode(":", $webSafe);
             // skip all the ones that wont go on this page
             if (strcmp($webSafe, $current) != 0) {
                 continue;
             }
             $feed = new SimplePie();
             $feed->feed_url($feedInfo['url']);
             $feed->cache_location(Core::getBaseDir() . DIRECTORY_SEPARATOR . 'cache');
             $feed->replace_headers(true);
             $feed->init();
             if ($feed->data) {
                 $max = $feed->get_item_quantity(0);
                 $templateMgr->assign('feed', $feed);
                 for ($x = 0; $x < $max; $x++) {
                     $item = $feed->get_item($x);
                     $templateMgr->assign('item', $item);
                     $items[$item->get_date('U')] = trim($templateMgr->fetch($this->getTemplatePath() . 'rss.tpl'));
                 }
             }
         }
         if (is_array($items) && count($items) > 0) {
             if ($aggregate) {
                 krsort($items);
             }
             foreach ($items as $time => $post) {
                 if ($months > 0) {
                     if ($time > strtotime("-" . $months . " month")) {
                         $output .= $post;
                     }
                 } else {
                     $output .= $post;
                 }
             }
         }
     }
     return false;
 }
开发者ID:alenoosh,项目名称:ojs,代码行数:55,代码来源:CmsRssPlugin.inc.php

示例6: plan_read_sources_feed

function plan_read_sources_feed($url)
{
    $url = str_replace("feed://", "http://", $url);
    if (!strstr($url, '://')) {
        $url = plan_get_real_location($url);
    }
    $feed = new SimplePie();
    $feed->feed_url($url);
    $feed->output_encoding('utf-8');
    $feed->init();
    $feed->handle_content_type();
    $title = $feed->get_feed_title();
    $items = $feed->get_items();
    foreach ($items as $item) {
        $timecode = $item->get_date();
        $item_title = $item->get_title();
        $item_description = $item->get_description();
        if ($item_title == $item_description) {
            $item_title = '';
        }
        if ($item_description != $last_description) {
            if ($last_timecode - $timecode > 300 || !$last_timecode) {
                $entries["{$timecode}"] = "<a href='/read/{$url}'>{$title}</a>: <h4>" . $item_title . "</h4>" . $item_description;
                $last_timecode = $timecode;
            } else {
                $entries["{$last_timecode}"] .= "<br />\n" . $item_description;
            }
        }
        $last_description = $item_description;
    }
    return $entries;
}
开发者ID:joshuawdavidson,项目名称:planwatch,代码行数:32,代码来源:plan_read.php


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