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


PHP SimplePie::get_channel_tags方法代码示例

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


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

示例1: discover_favicon

 /**
  * Find the feed's icon
  *
  * @param SimplePie $feed SimplePie object to retrieve logo for
  * @return string URL to feed icon
  */
 protected static function discover_favicon($feed, $id)
 {
     if ($return = $feed->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) {
         $favicon = SimplePie_Misc::absolutize_url($return[0]['data'], $feed->get_base($return[0]));
     } elseif (($url = $feed->get_link()) !== null && preg_match('/^http(s)?:\\/\\//i', $url)) {
         $filename = $id . '.ico';
         $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
     } else {
         return false;
     }
     $cache = new DataHandler(get_option('cachedir'));
     $request = new HTTPRequest();
     $file = $request->get($favicon, array('X-Forwarded-For' => $_SERVER['REMOTE_ADDR']));
     if ($file->success && strlen($file->body) > 0) {
         $sniffer = new $feed->content_type_sniffer_class($file);
         if (substr($sniffer->get_type(), 0, 6) === 'image/') {
             $body = array('type' => $sniffer->get_type(), 'body' => $file->body);
             return $cache->save($filename, serialize($body));
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:30,代码来源:class-feeds.php

示例2: SimplePie

 function generate_post()
 {
     if ($this->o["feed_url"] == "") {
         return;
     }
     $rss = new SimplePie();
     $rss->set_feed_url($this->o["feed_url"]);
     $rss->enable_cache(false);
     $rss->enable_order_by_date(false);
     $rss->init();
     $updated = $rss->get_channel_tags("http://www.w3.org/2005/Atom", "updated");
     $last_update = strtotime(str_replace(array("T", "Z"), " ", $updated[0]["data"]));
     $new_items = array();
     $post_content = "";
     $newtime = 0;
     if ($this->o["last_refresh_feed"] < $last_update) {
         foreach ($rss->get_items() as $item) {
             $entry_time = strtotime($item->get_local_date());
             $crawl_time = $item->data["attribs"]["http://www.google.com/schemas/reader/atom/"]["crawl-timestamp-msec"];
             if ($newtime == 0) {
                 $newtime = $crawl_time;
             }
             if ($this->o["last_crawl"] < $crawl_time) {
                 $new_item["crawl_time"] = $crawl_time;
                 $new_item["entry_time"] = $entry_time;
                 $new_item["title"] = $item->get_title();
                 $new_item["link"] = $this->get_origin_url($item->get_link());
                 if ($source = $item->get_source()) {
                     $new_item['site_url'] = $source->get_link(0);
                     $new_item['site_name'] = $source->get_title();
                 }
                 $annotation = $item->get_item_tags("http://www.google.com/schemas/reader/atom/", "annotation");
                 if (isset($annotation)) {
                     $note = html_entity_decode($this->o["post_note_template"]);
                     $note = str_replace(array_keys($this->annotation_elements), array($annotation[0]["child"]["http://www.w3.org/2005/Atom"]["content"][0]["data"], $annotation[0]["child"]["http://www.w3.org/2005/Atom"]["author"][0]["child"]["http://www.w3.org/2005/Atom"]["name"][0]["data"]), $note);
                 } else {
                     $note = "";
                 }
                 $new_item["note"] = $note;
                 $new_items[] = $new_item;
             }
         }
         if (count($new_items) > 0) {
             foreach ($new_items as $item) {
                 $item_date = date(get_option("date_format"), $item["entry_time"]);
                 $import = html_entity_decode($this->o["post_item_template"]);
                 $import = str_replace(array_keys($this->item_elements), array($item["title"], $item["link"], $item_date, $item["note"], $item["site_name"], $item["site_url"]), $import);
                 $post_content .= $import;
             }
         }
     }
     if ($post_content != "") {
         $post_title = html_entity_decode($this->o["post_title"]);
         $post_title = str_replace(array_keys($this->title_elements), date(get_option("date_format")), $post_title);
         $post_header = html_entity_decode($this->o["post_header_template"]);
         $post_footer = html_entity_decode($this->o["post_footer_template"]);
         $new_post = array();
         $new_post['comment_status'] = $this->o["post_comments"] == 1 ? 'open' : 'closed';
         $new_post['post_author'] = $this->o["post_author"];
         $new_post['post_content'] = $post_header . $post_content . $post_footer;
         $new_post['post_status'] = 'publish';
         $new_post['post_title'] = $post_title;
         $new_post['post_type'] = 'post';
         $new_post['post_category'] = array($this->o["post_category"]);
         $new_post['tags_input'] = $this->o["post_tags"];
         wp_insert_post($new_post);
         $this->o["last_refresh_feed"] = $last_update;
         $this->o["last_refresh"] = mktime();
         $this->o["last_crawl"] = $newtime;
         update_option($this->options_key, $this->o);
     }
 }
开发者ID:jardenberg,项目名称:SharedItems2WP,代码行数:72,代码来源:SharedItems2WP.php

示例3: SimplePie

        function get_total_results($url)
        {
            $response = $this->oauth_get($url,array('max-results' => 1, 'start-index' => 2));

            $feed = new SimplePie();
            $feed->set_raw_data($response);
            $feed->init();
            $results = $feed->get_channel_tags('http://a9.com/-/spec/opensearchrss/1.0/', 'totalResults');

            $total_results = $results[0]['data'];
            unset($feed);
            return (int)$total_results;
        }
开发者ID:niamherinoc,项目名称:rctractors,代码行数:13,代码来源:blogger-importer-connector.php

示例4: die


//.........这里部分代码省略.........
         } 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);
             $rss->init();
             $ferror = $rss->error();
             // go back to original URL if error persisted
             if (stripos($ferror, 'invalid')) {
                 //get raw file to show any errors
                 @(include_once ABSPATH . WPINC . '/SimplePie/File.php');
                 if (class_exists('SimplePie_File')) {
                     $rawfile = new SimplePie_File($suburl, $rss->timeout, 5, null, $rss->useragent, $rss->force_fsockopen);
                 } elseif (class_exists($rss->file_class)) {
                     $rawfile = new $rss->file_class($suburl, $rss->timeout, 5, null, $rss->useragent, $rss->force_fsockopen);
                 }
                 if (isset($rawfile->body)) {
                     $rawfile = $rawfile->body;
                 } else {
                     $rawfile = __('Raw file could not be found', $this->plugin_domain);
                 }
             }
         }
     }
     $rss->handle_content_type();
     $gen = $rss->get_channel_tags('', 'generator');
     $prem_msg = $rss->get_channel_tags('', 'prem_msg');
     $g = $num;
     $p = 'u';
     $meta = array();
     //DebugBreak();
     if ($gen && strstr($gen[0]['data'], 'commentluv')) {
         $generator = $gen[0]['data'];
         $meta['generator'] = $generator;
         $pos = stripos($generator, 'v=');
         if (substr($generator, $pos + 2, 1) == '3') {
             $g = 15;
             $p = 'p';
         }
     }
     if ($prem_msg) {
         $prem_msg = $prem_msg[0]['data'];
     }
     //DebugBreak();
     $error = $rss->error();
     $meta['used_feed'] = $rss->subscribe_url();
     //DebugBreak();
     // no error, construct return json
     if (!$error) {
         $arr = array();
         // save meta
         $meta['used_feed'] = $rss->subscribe_url();
         $feed_items = $rss->get_items();
         foreach ($feed_items as $item) {
             //debugbreak();
             $type = 'blog';
             $itemtags = $item->get_item_tags('', 'type');
             if ($itemtags) {
开发者ID:lykeven,项目名称:graspzhihu,代码行数:67,代码来源:commentluv.php


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