本文整理汇总了PHP中Requests::transport方法的典型用法代码示例。如果您正苦于以下问题:PHP Requests::transport方法的具体用法?PHP Requests::transport怎么用?PHP Requests::transport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requests
的用法示例。
在下文中一共展示了Requests::transport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}