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


PHP SimplePie::set_item_class方法代码示例

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


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

示例1: get_feed_items

function get_feed_items()
{
    // go through all the feed urls
    $items = array();
    $feeds = ORM::for_table('feeds')->find_many();
    foreach ($feeds as $feed_loc) {
        $feed = new SimplePie();
        $feed->set_feed_url($feed_loc->location);
        $feed->set_cache_location("mysql://" . DB_USER . ":" . DB_PASS . "@" . DB_HOST . ":3306/" . DB_NAME);
        $feed->set_item_class('MyItemClass');
        $feed->init();
        $feed->handle_content_type();
        $items = array_merge($items, $feed->get_items());
    }
    return $items;
}
开发者ID:kmwenja,项目名称:cuterss,代码行数:16,代码来源:index.php

示例2: SimplePie

<?php

include_once 'simplepie.inc';
include_once 'simplepie_youtube.inc';
$feed = new SimplePie();
// Create a new instance of SimplePie
$feed->set_feed_url('http://gdata.youtube.com/feeds/api/playlists/957F7A8A7B24D497');
$feed->set_cache_duration(600);
//The cache duration
$feed->set_item_class('SimplePie_Item_YouTube');
$feed->enable_xml_dump(isset($_GET['xmldump']) ? true : false);
$success = $feed->init();
// Initialize SimplePie
$feed->handle_content_type();
// Take care of the character encoding
?>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>YouTube + Simple Pie Sample</title>
</head>
<body>
<h1><a href="<?php 
echo $feed->get_permalink();
?>
"><?php 
echo $feed->get_title();
?>
</a></h1>
<?php 
foreach ($feed->get_items() as $item) {
开发者ID:TheProjecter,项目名称:simplepie-youtube-addon,代码行数:31,代码来源:final_playlist.php

示例3: array

 function import_blog($blogID)
 {
     global $importing_blog;
     $importing_blog = $blogID;
     if (isset($_GET['authors'])) {
         return print $this->get_author_form();
     }
     if (isset($_GET['status'])) {
         self::ajax_die($this->get_js_status());
     }
     if (isset($_GET['saveauthors'])) {
         self::ajax_die($this->save_authors());
     }
     //Simpler counting for posts as we load them forwards
     if (isset($this->blogs[$importing_blog]['posts_start_index'])) {
         $start_index = (int) $this->blogs[$importing_blog]['posts_start_index'];
     } else {
         $start_index = 1;
     }
     // This will be positive until we have finished importing posts
     if ($start_index > 0) {
         // Grab all the posts
         $this->blogs[$importing_blog]['mode'] = 'posts';
         do {
             $index = $struct = $entries = array();
             $url = $this->blogs[$importing_blog]['posts_url'];
             $response = $this->oauth_get($url, array('max-results' => MAX_RESULTS, 'start-index' => $start_index));
             if ($response == false) {
                 break;
             }
             // parse the feed
             $feed = new SimplePie();
             $feed->set_item_class('WP_SimplePie_Blog_Item');
             $feed->set_sanitize_class('Blogger_Importer_Sanitize');
             $feed->set_raw_data($response);
             $feed->init();
             foreach ($feed->get_items() as $item) {
                 $blogentry = new BloggerEntry();
                 $blogentry->id = $item->get_id();
                 $blogentry->published = $item->get_published();
                 $blogentry->updated = $item->get_updated();
                 $blogentry->isDraft = $item->get_draft_status($item);
                 $blogentry->title = $item->get_title();
                 $blogentry->content = $item->get_content();
                 $blogentry->author = $item->get_author()->get_name();
                 $blogentry->geotags = $item->get_geotags();
                 $linktypes = array('replies', 'edit', 'self', 'alternate');
                 foreach ($linktypes as $type) {
                     $links = $item->get_links($type);
                     if (!is_null($links)) {
                         foreach ($links as $link) {
                             $blogentry->links[] = array('rel' => $type, 'href' => $link);
                         }
                     }
                 }
                 $cats = $item->get_categories();
                 if (!is_null($cats)) {
                     foreach ($cats as $cat) {
                         $blogentry->categories[] = $cat->term;
                     }
                 }
                 $result = $this->import_post($blogentry);
                 //Ref: Not importing properly http://core.trac.wordpress.org/ticket/19096
                 //Simplified this section to count what is loaded rather than parsing the results again
                 $start_index++;
             }
             $this->blogs[$importing_blog]['posts_start_index'] = $start_index;
             $this->save_vars();
         } while ($this->blogs[$importing_blog]['total_posts'] > $start_index && $this->have_time());
         //have time function will "die" if it's out of time
     }
     if (isset($this->blogs[$importing_blog]['comments_start_index'])) {
         $start_index = (int) $this->blogs[$importing_blog]['comments_start_index'];
     } else {
         $start_index = 1;
     }
     if ($start_index > 0 && $this->blogs[$importing_blog]['total_comments'] > 0) {
         $this->blogs[$importing_blog]['mode'] = 'comments';
         do {
             $index = $struct = $entries = array();
             //So we can link up the comments as we go we need to load them in reverse order
             //Reverse the start index as the GData Blogger feed can't be sorted
             $batch = floor(($this->blogs[$importing_blog]['total_comments'] - $start_index) / MAX_RESULTS) * MAX_RESULTS + 1;
             $response = $this->oauth_get($this->blogs[$importing_blog]['comments_url'], array('max-results' => MAX_RESULTS, 'start-index' => $batch));
             // parse the feed
             $feed = new SimplePie();
             $feed->set_item_class('WP_SimplePie_Blog_Item');
             // Use the standard "stricter" sanitize class for comments
             $feed->set_raw_data($response);
             $feed->init();
             //Reverse the batch so we load the oldest comments first and hence can link up nested comments
             $comments = array_reverse($feed->get_items());
             if (!is_null($comments)) {
                 foreach ($comments as $item) {
                     $blogentry = new BloggerEntry();
                     $blogentry->id = $item->get_id();
                     $blogentry->updated = $item->get_updated();
                     $blogentry->content = $item->get_content();
                     $blogentry->author = $item->get_author()->get_name();
                     $blogentry->authoruri = $item->get_author()->get_link();
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:blogger-importer.php


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