Curl\Curl::__construct PHP Method

__construct() public method

Construct
public __construct ( $base_url = null )
$base_url
    public function __construct($base_url = null)
    {
        if (!extension_loaded('curl')) {
            throw new \ErrorException('cURL library is not loaded');
        }
        $this->curl = curl_init();
        $this->id = uniqid('', true);
        $this->setDefaultUserAgent();
        $this->setDefaultJsonDecoder();
        $this->setDefaultXmlDecoder();
        $this->setDefaultTimeout();
        $this->setOpt(CURLINFO_HEADER_OUT, true);
        $this->setOpt(CURLOPT_HEADERFUNCTION, array($this, 'headerCallback'));
        $this->setOpt(CURLOPT_RETURNTRANSFER, true);
        $this->headers = new CaseInsensitiveArray();
        $this->setUrl($base_url);
    }

Usage Example

Example #1
0
 /**
  *	Конструктор
  *
  *	@param	string	$base_url
  */
 public function __construct($base_url = null)
 {
     parent::__construct($base_url);
     $this->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $this->setJsonDecoder(function ($response) {
         if (($json_obj = json_decode($response, true)) !== null) {
             return $json_obj;
         }
         return $response;
     });
 }
All Usage Examples Of Curl\Curl::__construct