Zend_Http_Client::setConfig PHP Method

setConfig() public method

Set configuration parameters for this HTTP client
public setConfig ( $config = [] ) : Zend_Http_Client
return Zend_Http_Client
    public function setConfig($config = array())
    {
        if ($config instanceof Zend_Config) {
            $config = $config->toArray();
        } elseif (!is_array($config)) {
            /** @see Zend_Http_Client_Exception */
            require_once 'Zend/Http/Client/Exception.php';
            throw new Zend_Http_Client_Exception('Array or Zend_Config object expected, got ' . gettype($config));
        }
        foreach ($config as $k => $v) {
            $this->config[strtolower($k)] = $v;
        }
        // Pass configuration options to the adapter if it exists
        if ($this->adapter instanceof Zend_Http_Client_Adapter_Interface) {
            $this->adapter->setConfig($config);
        }
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Initialises an instance of the RecensusApi class.
  * 
  * @param string  $merchantId      Identifying token given to merchants by Recensus
  * @param string  $merchantSecret  Secret shared between merchant and Recensus for hashing requests.
  * @param boolean $throwExceptions If true will throw exceptions rather than emit notices.
  * 
  * @return void
  */
 public function __construct($merchantId, $merchantSecret, $throwExceptions = false)
 {
     $this->merchantId = $merchantId;
     $this->merchantSecret = $merchantSecret;
     $this->throwExceptions = $throwExceptions;
     $this->httpClient = new Zend_Http_Client();
     $this->httpClient->setConfig(array("timeout" => 3));
 }
All Usage Examples Of Zend_Http_Client::setConfig