本文整理汇总了PHP中Zend_Http_Client_Adapter_Interface::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client_Adapter_Interface::setConfig方法的具体用法?PHP Zend_Http_Client_Adapter_Interface::setConfig怎么用?PHP Zend_Http_Client_Adapter_Interface::setConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Client_Adapter_Interface
的用法示例。
在下文中一共展示了Zend_Http_Client_Adapter_Interface::setConfig方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setClientAdapter
/**
* Set adapter for client
*
* @param array $client
* @return Zend_Auth_Adapter_Cas
*/
public function setClientAdapter($client = array())
{
extract($client);
$adapter = isset($adapter) ? $adapter : 'Zend_Http_Client_Adapter_Socket';
$options = isset($options) ? $options : array();
$this->_clientAdapter = new $adapter();
$this->_clientAdapter->setConfig($options);
return $this;
}
示例2: __construct
/**
* Contructor method. Will create a new HTTP client. Accepts the target
* URL and optionally and array of headers.
*
* @param Zend_Uri_Http|string $uri
* @param array $headers Optional request headers to set
*/
public function __construct($uri = null, $config = null)
{
if ($uri !== null) {
$this->setUri($uri);
}
if ($config !== null) {
$this->setConfig($config);
}
Zend::loadClass($this->config['adapter']);
$this->adapter = new $this->config['adapter']();
$this->adapter->setConfig(array('timeout' => $this->config['timeout']));
}
示例3: setAdapter
/**
* Load the connection adapter
*
* While this method is not called more than one for a client, it is
* seperated from ->request() to preserve logic and readability
*
* @param Zend_Http_Client_Adapter_Interface|string $adapter
* @return null
* @throws Zend_Http_Client_Exception
*/
public function setAdapter($adapter)
{
if (is_string($adapter)) {
if (!Sabel::using($adapter)) {
throw new Sabel_Exception_ClassNotFound($adapter);
}
$adapter = new $adapter();
}
if (!$adapter instanceof Sabel_Http_Client_Adapter_Interface) {
$message = __METHOD__ . "() Passed adapter is not a HTTP connection adapter.";
throw new Sabel_Exception_InvalidArgument($message);
}
$this->adapter = $adapter;
$config = $this->config;
unset($config["adapter"]);
$this->adapter->setConfig($config);
}
示例4: setAdapter
/**
* Load the connection adapter
*
* While this method is not called more than one for a client, it is
* seperated from ->request() to preserve logic and readability
*
* @param Zend_Http_Client_Adapter_Interface|string $adapter
*/
public function setAdapter($adapter)
{
if (is_string($adapter)) {
try {
Zend_Loader::loadClass($adapter);
} catch (Zend_Exception $e) {
throw new Zend_Http_Client_Exception("Unable to load adapter '{$adapter}': {$e->getMessage()}");
}
$adapter = new $adapter();
}
if (!$adapter instanceof Zend_Http_Client_Adapter_Interface) {
throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
}
$this->adapter = $adapter;
$config = $this->config;
unset($config['adapter']);
$this->adapter->setConfig($config);
}
示例5: _postBack
/**
* Post back to PayPal to check whether this request is a valid one
*
* @param Zend_Http_Client_Adapter_Interface $httpAdapter
*/
protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
{
$postbackQuery = http_build_query($this->_request) . '&cmd=_notify-validate';
$postbackUrl = $this->_config->getPaypalUrl();
$this->_debugData['postback_to'] = $postbackUrl;
$httpAdapter->setConfig(array('verifypeer' => $this->_config->verifyPeer));
$httpAdapter->write(Zend_Http_Client::POST, $postbackUrl, '1.1', array('Connection: close'), $postbackQuery);
try {
$postbackResult = $httpAdapter->read();
} catch (Exception $e) {
$this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
throw $e;
}
$response = preg_split('/^\\r?$/m', $postbackResult, 2);
$response = trim($response[1]);
if ($response != 'VERIFIED') {
$this->_debugData['postback'] = $postbackQuery;
$this->_debugData['postback_result'] = $postbackResult;
throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
}
}
示例6: setAdapter
/**
* Load the connection adapter
*
* While this method is not called more than one for a client, it is
* seperated from ->request() to preserve logic and readability
*
* @param Zend_Http_Client_Adapter_Interface|string $adapter
* @return null
* @throws Zend_Http_Client_Exception
*/
public function setAdapter($adapter)
{
if (is_string($adapter)) {
if (!class_exists($adapter)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($adapter);
} catch (Zend_Exception $e) {
/** @see Zend_Http_Client_Exception */
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception("Unable to load adapter '{$adapter}': {$e->getMessage()}", 0, $e);
}
}
$adapter = new $adapter();
}
if (!$adapter instanceof Zend_Http_Client_Adapter_Interface) {
/** @see Zend_Http_Client_Exception */
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
}
$this->adapter = $adapter;
$config = $this->config;
unset($config['adapter']);
$this->adapter->setConfig($config);
}
示例7: _postBack
/**
* Post back to PayPal to check whether this request is a valid one
*
* @param Zend_Http_Client_Adapter_Interface $httpAdapter
*/
protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
{
$postbackQuery = http_build_query($this->_request) . '&cmd=_notify-validate';
$postbackUrl = $this->_config->getPaypalUrl();
$this->_debugData['postback_to'] = $postbackUrl;
$httpAdapter->setConfig(array('verifypeer' => $this->_config->verifyPeer));
$httpAdapter->write(Zend_Http_Client::POST, $postbackUrl, '1.1', array('Connection: close'), $postbackQuery);
try {
$postbackResult = $httpAdapter->read();
} catch (Exception $e) {
$this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
throw $e;
}
/*
* Handle errors on PayPal side.
*/
$responseCode = Zend_Http_Response::extractCode($postbackResult);
if (empty($postbackResult) || in_array($responseCode, array('500', '502', '503'))) {
if (empty($postbackResult)) {
$reason = 'Empty response.';
} else {
$reason = 'Response code: ' . $responseCode . '.';
}
$this->_debugData['exception'] = 'PayPal IPN postback failure. ' . $reason;
throw new Mage_Paypal_UnavailableException($reason);
}
$response = preg_split('/^\\r?$/m', $postbackResult, 2);
$response = trim($response[1]);
if ($response != 'VERIFIED') {
$this->_debugData['postback'] = $postbackQuery;
$this->_debugData['postback_result'] = $postbackResult;
throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
}
}
示例8: _postBack
/**
* Post back to PayPal to check whether this request is a valid one
*
* @param Zend_Http_Client_Adapter_Interface $httpAdapter
*/
protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
{
$sReq = '';
foreach ($this->_request as $k => $v) {
$sReq .= '&' . $k . '=' . urlencode($v);
}
$sReq .= "&cmd=_notify-validate";
$sReq = substr($sReq, 1);
$this->_debugData['postback'] = $sReq;
$this->_debugData['postback_to'] = $this->_config->getPaypalUrl();
$httpAdapter->setConfig(array('verifypeer' => $this->_config->verifyPeer));
$httpAdapter->write(Zend_Http_Client::POST, $this->_config->getPaypalUrl(), '1.1', array(), $sReq);
try {
$response = $httpAdapter->read();
} catch (Exception $e) {
$this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
throw $e;
}
$this->_debugData['postback_result'] = $response;
$response = preg_split('/^\\r?$/m', $response, 2);
$response = trim($response[1]);
if ($response != 'VERIFIED') {
throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
}
unset($this->_debugData['postback'], $this->_debugData['postback_result']);
}
示例9: setAdapter
/**
* Load the connection adapter
*
* While this method is not called more than one for a client, it is
* seperated from ->request() to preserve logic and readability
*
* @param Zend_Http_Client_Adapter_Interface|string $adapter
* @return null
* @throws Zend_Http_Client_Exception
*/
public function setAdapter($adapter)
{
if (is_string($adapter)) {
if (!class_exists($adapter)) {
try {
//require_once (JPATH_LIBRARIES.DS.'zend'.DS.'Loader.php');
jimport('zend.Http.Client.Adapter.Socket');
} catch (Zend_Exception $e) {
/** @see Zend_Http_Client_Exception */
require_once JPATH_LIBRARIES . DS . 'zend' . DS . 'Http' . DS . 'Client' . DS . 'Exception.php';
throw new Zend_Http_Client_Exception("Unable to load adapter '{$adapter}': {$e->getMessage()}");
}
}
$adapter = new $adapter();
}
if (!$adapter instanceof Zend_Http_Client_Adapter_Interface) {
/** @see Zend_Http_Client_Exception */
require_once JPATH_LIBRARIES . DS . 'zend' . DS . 'Http' . DS . 'Client' . DS . 'Exception.php';
throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
}
$this->adapter = $adapter;
$config = $this->config;
unset($config['adapter']);
$this->adapter->setConfig($config);
}
示例10: setAdapter
/**
* Load the connection adapter
*
* While this method is not called more than one for a client, it is
* seperated from ->request() to preserve logic and readability
*
* @param Zend_Http_Client_Adapter_Interface|string $adapter
* @return null
* @throws Zend_Http_Client_Exception
*/
public function setAdapter($adapter)
{
if (is_string($adapter)) {
if (!class_exists($adapter)) {
try {
/*require_once JPATH_COMPONENT . DS . 'lib' . DS . 'Zend/Loader.php';
Zend_Loader::loadClass($adapter);*/
$adapterName = str_replace('Zend_Http_Client_Adapter_', '', $adapter);
require_once JPATH_COMPONENT . DS . 'lib' . DS . 'Zend' . DS . 'Http' . DS . 'Client' . DS . 'Adapter' . DS . ucfirst($adapterName) . '.php';
} catch (Zend_Exception $e) {
/** @see Zend_Http_Client_Exception */
require_once JPATH_COMPONENT . DS . 'lib' . DS . 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception("Unable to load adapter '{$adapter}': {$e->getMessage()}", 0, $e);
}
}
$adapter = new $adapter();
}
if (!$adapter instanceof Zend_Http_Client_Adapter_Interface) {
/** @see Zend_Http_Client_Exception */
require_once JPATH_COMPONENT . DS . 'lib' . DS . 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
}
$this->adapter = $adapter;
$config = $this->config;
unset($config['adapter']);
$this->adapter->setConfig($config);
}