本文整理汇总了PHP中Zend_Http_Client_Adapter_Socket::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client_Adapter_Socket::setConfig方法的具体用法?PHP Zend_Http_Client_Adapter_Socket::setConfig怎么用?PHP Zend_Http_Client_Adapter_Socket::setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Client_Adapter_Socket
的用法示例。
在下文中一共展示了Zend_Http_Client_Adapter_Socket::setConfig方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAdapterFromConfig
/**
* @param Enlight_Config $config
* @see https://github.com/paypal/sdk-core-php
* @return Zend_Http_Client_Adapter_Curl|Zend_Http_Client_Adapter_Socket
*/
public static function createAdapterFromConfig($config)
{
$curl = $config->get('paypalCurl', true);
$sslVersion = $config->get('paypalSslVersion', 0);
$timeout = $config->get('paypalTimeout') ?: 60;
$userAgent = 'Shopware/' . Shopware::VERSION;
if ($curl && extension_loaded('curl')) {
$adapter = new Zend_Http_Client_Adapter_Curl();
$adapter->setConfig(array('useragent' => $userAgent, 'timeout' => $timeout));
if (!empty($config->paypalSandbox)) {
$adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
$adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, false);
}
$adapter->setCurlOption(CURLOPT_TIMEOUT, $timeout);
$adapter->setCurlOption(CURLOPT_SSLVERSION, $sslVersion);
//$adapter->setCurlOption(CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
//$adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
//$adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
} else {
$adapter = new Zend_Http_Client_Adapter_Socket();
$adapter->setConfig(array('useragent' => $userAgent, 'timeout' => $timeout, 'ssltransport' => $sslVersion > 3 || $sslVersion == 1 ? 'tls' : 'ssl'));
}
return $adapter;
}
示例2: getRestClient
/**
* Returns a reference to the REST client
*
* @return Zend_Rest_Client
*/
public function getRestClient()
{
if ($this->_rest === null) {
/**
* @see Zend_Rest_Client
*/
require_once 'Zend/Rest/Client.php';
$this->_rest = new Zend_Rest_Client();
/**
* @see Zend_Http_Client
*/
require_once 'Zend/Http/Client.php';
$httpClient = new Zend_Http_Client($this->_baseUri, array('keepalive' => $this->_usePersistentConnections));
/**
* The Ticket Evolution Sandbox uses a self-signed certificate which,
* by default is not allowed. If we are using https in the sandbox lets
* tweak the options to allow this self-signed certificate.
*
* @link http://framework.zend.com/manual/en/zend.http.client.adapters.html Example 2
*/
if (strpos($this->_baseUri, 'sandbox') !== false) {
$streamOptions = array('ssl' => array('allow_self_signed' => true));
} else {
$streamOptions = array();
}
/**
* Create an adapter object and attach it to the HTTP client
*
* @see Zend_Http_Client_Adapter_Socket
*/
require_once 'Zend/Http/Client/Adapter/Socket.php';
$adapter = new Zend_Http_Client_Adapter_Socket();
$adapterConfig = array('persistent' => $this->_usePersistentConnections);
$adapter->setConfig($adapterConfig);
$httpClient->setAdapter($adapter);
// Pass the streamOptions array to setStreamContext()
$adapter->setStreamContext($streamOptions);
$this->_rest->setHttpClient($httpClient);
}
return $this->_rest;
}