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


PHP Requests::transports方法代码示例

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


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

示例1: get_transport

 /**
  * Get a working transport
  *
  * @return Requests_Transport
  */
 protected static function get_transport()
 {
     if (!is_null(self::$transport)) {
         return new self::$transport();
     }
     if (empty(self::$transports)) {
         self::$transports = array('Requests_Transport_cURL', 'Requests_Transport_fsockopen');
     }
     // Find us a working transport
     foreach (self::$transports as $class) {
         if (!class_exists($class)) {
             continue;
         }
         $result = call_user_func(array($class, 'test'));
         if ($result) {
             self::$transport = $class;
             break;
         }
     }
     if (self::$transport === null) {
         throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
     }
     return new self::$transport();
 }
开发者ID:rmccue,项目名称:Gorilla,代码行数:29,代码来源:Requests.php

示例2: get_transport

 /**
  * Get a working transport
  *
  * @throws Requests_Exception If no valid transport is found (`notransport`)
  * @return Requests_Transport
  */
 protected static function get_transport()
 {
     // Caching code, don't bother testing coverage
     // @codeCoverageIgnoreStart
     if (self::$transport !== null) {
         return new self::$transport();
     }
     // @codeCoverageIgnoreEnd
     if (empty(self::$transports)) {
         self::$transports = ['Requests_Transport_cURL', 'Requests_Transport_fsockopen'];
     }
     // Find us a working transport
     foreach (self::$transports as $class) {
         if (!class_exists($class)) {
             continue;
         }
         $result = call_user_func([$class, 'test']);
         if ($result) {
             self::$transport = $class;
             break;
         }
     }
     if (self::$transport === null) {
         throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
     }
     return new self::$transport();
 }
开发者ID:jamesmstone,项目名称:OUTDATED-ifttt-fitbit,代码行数:33,代码来源:Requests.php

示例3: get_transport

 /**
  * Get a working transport
  *
  * @throws Requests_Exception If no valid transport is found (`notransport`)
  * @return Requests_Transport
  */
 protected static function get_transport($capabilities = array())
 {
     // Caching code, don't bother testing coverage
     // @codeCoverageIgnoreStart
     // array of capabilities as a string to be used as an array key
     ksort($capabilities);
     $cap_string = serialize($capabilities);
     // Don't search for a transport if it's already been done for these $capabilities
     if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) {
         return new self::$transport[$cap_string]();
     }
     // @codeCoverageIgnoreEnd
     if (empty(self::$transports)) {
         self::$transports = array('Requests_Transport_cURL', 'Requests_Transport_fsockopen');
     }
     // Find us a working transport
     foreach (self::$transports as $class) {
         if (!class_exists($class)) {
             continue;
         }
         $result = call_user_func(array($class, 'test'), $capabilities);
         if ($result) {
             self::$transport[$cap_string] = $class;
             break;
         }
     }
     if (self::$transport[$cap_string] === null) {
         throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
     }
     return new self::$transport[$cap_string]();
 }
开发者ID:proj-2014,项目名称:tmp-test,代码行数:37,代码来源:Requests.php


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