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


PHP SimplePie_Misc::compress_parse_url方法代码示例

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


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

示例1: __construct

 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
 {
     if (class_exists('idna_convert')) {
         $idn = new idna_convert();
         $parsed = SimplePie_Misc::parse_url($url);
         $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
     }
     $this->url = $url;
     $this->useragent = $useragent;
     if (preg_match('/^http(s)?:\\/\\//i', $url)) {
         if (!is_array($headers)) {
             $headers = array();
         }
         $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
         $headers2 = array();
         foreach ($headers as $key => $value) {
             $headers2[] = "{$key}: {$value}";
         }
         //TODO: allow for HTTP headers
         // curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
         $response = self::$agent->get($url);
         if ($response === false || !isset($response['status_code'])) {
             $this->error = 'failed to fetch URL';
             $this->success = false;
         } else {
             // The extra lines at the end are there to satisfy SimplePie's HTTP parser.
             // The class expects a full HTTP message, whereas we're giving it only
             // headers - the new lines indicate the start of the body.
             $parser = new SimplePie_HTTP_Parser($response['headers'] . "\r\n\r\n");
             if ($parser->parse()) {
                 $this->headers = $parser->headers;
                 //$this->body = $parser->body;
                 $this->body = $response['body'];
                 $this->status_code = $parser->status_code;
             }
         }
     } else {
         $this->error = 'invalid URL';
         $this->success = false;
     }
 }
开发者ID:jaimejorge,项目名称:ftr-site-config-build,代码行数:41,代码来源:SimplePie_HumbleHttpAgent.php

示例2: __construct

 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
 {
     if (class_exists('idna_convert')) {
         $idn = new idna_convert();
         $parsed = SimplePie_Misc::parse_url($url);
         $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
     }
     $this->url = $url;
     $this->useragent = $useragent;
     if (preg_match('/^http(s)?:\\/\\//i', $url)) {
         if ($useragent === null) {
             $useragent = ini_get('user_agent');
             $this->useragent = $useragent;
         }
         if (!is_array($headers)) {
             $headers = array();
         }
         if (!$force_fsockopen && function_exists('curl_exec')) {
             $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
             $fp = curl_init();
             $headers2 = array();
             foreach ($headers as $key => $value) {
                 $headers2[] = "{$key}: {$value}";
             }
             if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) {
                 curl_setopt($fp, CURLOPT_ENCODING, '');
             }
             curl_setopt($fp, CURLOPT_URL, $url);
             curl_setopt($fp, CURLOPT_HEADER, 1);
             curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
             curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
             curl_setopt($fp, CURLOPT_REFERER, $url);
             curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
             curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
             if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) {
                 curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
             }
             $this->headers = curl_exec($fp);
             if (curl_errno($fp) === 23 || curl_errno($fp) === 61) {
                 curl_setopt($fp, CURLOPT_ENCODING, 'none');
                 $this->headers = curl_exec($fp);
             }
             if (curl_errno($fp)) {
                 $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
                 $this->success = false;
             } else {
                 $info = curl_getinfo($fp);
                 curl_close($fp);
                 $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
                 $this->headers = array_pop($this->headers);
                 $parser = new SimplePie_HTTP_Parser($this->headers);
                 if ($parser->parse()) {
                     $this->headers = $parser->headers;
                     $this->body = $parser->body;
                     $this->status_code = $parser->status_code;
                     if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
                         $this->redirects++;
                         $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
                         return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
                     }
                 }
             }
         } else {
             $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
             $url_parts = parse_url($url);
             $socket_host = $url_parts['host'];
             if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
                 $socket_host = "ssl://{$url_parts['host']}";
                 $url_parts['port'] = 443;
             }
             if (!isset($url_parts['port'])) {
                 $url_parts['port'] = 80;
             }
             $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
             if (!$fp) {
                 $this->error = 'fsockopen error: ' . $errstr;
                 $this->success = false;
             } else {
                 stream_set_timeout($fp, $timeout);
                 if (isset($url_parts['path'])) {
                     if (isset($url_parts['query'])) {
                         $get = "{$url_parts['path']}?{$url_parts['query']}";
                     } else {
                         $get = $url_parts['path'];
                     }
                 } else {
                     $get = '/';
                 }
                 $out = "GET {$get} HTTP/1.1\r\n";
                 $out .= "Host: {$url_parts['host']}\r\n";
                 $out .= "User-Agent: {$useragent}\r\n";
                 if (extension_loaded('zlib')) {
                     $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
                 }
                 if (isset($url_parts['user']) && isset($url_parts['pass'])) {
                     $out .= "Authorization: Basic " . base64_encode("{$url_parts['user']}:{$url_parts['pass']}") . "\r\n";
                 }
                 foreach ($headers as $key => $value) {
//.........这里部分代码省略.........
开发者ID:kosir,项目名称:wp-pipes,代码行数:101,代码来源:File.php

示例3: fix_protocol

 public static function fix_protocol($url, $http = 1)
 {
     $url = SimplePie_Misc::normalize_url($url);
     $parsed = SimplePie_Misc::parse_url($url);
     if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') {
         return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
     }
     if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) {
         return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
     }
     if ($http === 2 && $parsed['scheme'] !== '') {
         return "feed:{$url}";
     } elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') {
         return substr_replace($url, 'podcast', 0, 4);
     } elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') {
         return substr_replace($url, 'itpc', 0, 4);
     } else {
         return $url;
     }
 }
开发者ID:kadrim1,项目名称:metsayhistu,代码行数:20,代码来源:Misc.php

示例4: normalize_url

 function normalize_url($url)
 {
     $url = preg_replace_callback('/%([0-9A-Fa-f]{2})/', array('SimplePie_Misc', 'percent_encoding_normalization'), $url);
     $url = SimplePie_Misc::parse_url($url);
     $url['scheme'] = strtolower($url['scheme']);
     if ($url['authority'] !== '') {
         $url['authority'] = strtolower($url['authority']);
         $url['path'] = SimplePie_Misc::remove_dot_segments($url['path']);
     }
     return SimplePie_Misc::compress_parse_url($url['scheme'], $url['authority'], $url['path'], $url['query'], $url['fragment']);
 }
开发者ID:jojospaghettio,项目名称:wicketpixie,代码行数:11,代码来源:simplepie.php

示例5: __construct

 /**
  * Constructor, used to input the data
  *
  * For documentation on all the parameters, see the corresponding
  * properties and their accessors
  *
  * @uses idna_convert If available, this will convert an IDN
  */
 public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
 {
     $this->bitrate = $bitrate;
     $this->captions = $captions;
     $this->categories = $categories;
     $this->channels = $channels;
     $this->copyright = $copyright;
     $this->credits = $credits;
     $this->description = $description;
     $this->duration = $duration;
     $this->expression = $expression;
     $this->framerate = $framerate;
     $this->hashes = $hashes;
     $this->height = $height;
     $this->keywords = $keywords;
     $this->lang = $lang;
     $this->length = $length;
     $this->link = $link;
     $this->medium = $medium;
     $this->player = $player;
     $this->ratings = $ratings;
     $this->restrictions = $restrictions;
     $this->samplingrate = $samplingrate;
     $this->thumbnails = $thumbnails;
     $this->title = $title;
     $this->type = $type;
     $this->width = $width;
     if (class_exists('idna_convert')) {
         $idn = new idna_convert();
         $parsed = SimplePie_Misc::parse_url($link);
         $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
     }
     $this->handler = $this->get_handler();
     // Needs to load last
 }
开发者ID:vazahat,项目名称:dudex,代码行数:43,代码来源:Enclosure.php


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