public function open()
    {
        $url = $this->url;
        $headers = [];

        // Set query data if there is any
        if (count($this->fields) > 0) {
            if ($this->method == 'GET') {
                $url = $this->options[CURLOPT_URL].'?'.$this->getQuery();
                $this->setOption(CURLOPT_URL, $url);
            } else {
                if (isset($this->requestHeaders['Content-Type']) && ($this->requestHeaders['Content-Type'] != 'multipart/form-data')) {
                    $this->setOption(CURLOPT_POSTFIELDS, $this->getQuery());
                    $this->setRequestHeader('Content-Length', $this->getQueryLength());
                } else {
                    $this->setOption(CURLOPT_POSTFIELDS, $this->fields);
                }
                $this->setOption(CURLOPT_POSTFIELDS, $this->fields);
                $this->setOption(CURLOPT_URL, $url);
            }
        }

        if ($this->hasRequestHeaders()) {
            foreach ($this->requestHeaders as $header => $value) {
                $headers[] = $header.': '.$value;
            }
            $this->setOption(CURLOPT_HTTPHEADER, $headers);
        }

        $this->response = curl_exec($this->resource);

        if ($this->response === false) {
            $this->throwError('Error: '.curl_errno($this->resource).' => '.curl_error($this->resource).'.');
        }

        return $this;
    }
public function open()
    {
        $url = $this->url;
        $headers = [];

        // Set query data if there is any
        if (count($this->fields) > 0) {
            if ($this->method == 'GET') {
                $url = $this->options[CURLOPT_URL].'?'.$this->getQuery();
                $this->setOption(CURLOPT_URL, $url);
            } else {
                if (isset($this->requestHeaders['Content-Type']) && ($this->requestHeaders['Content-Type'] != 'multipart/form-data')) {
                    $this->setOption(CURLOPT_POSTFIELDS, $this->getQuery());
                    $this->setRequestHeader('Content-Length', $this->getQueryLength());
                } else {
                    $this->setOption(CURLOPT_POSTFIELDS, $this->fields);
                }
                $this->setOption(CURLOPT_POSTFIELDS, $this->fields);
                $this->setOption(CURLOPT_URL, $url);
            }
        }

        if ($this->hasRequestHeaders()) {
            foreach ($this->requestHeaders as $header => $value) {
                $headers[] = $header.': '.$value;
            }
            $this->setOption(CURLOPT_HTTPHEADER, $headers);
        }

        $this->response = curl_exec($this->resource);

        if ($this->response === false) {
            $this->throwError('Error: '.curl_errno($this->resource).' => '.curl_error($this->resource).'.');
        }

        return $this;
    }
public function open ( ) { $ url = $ this -> url ; $ headers = [ ] ; // Set query data if there is any if ( count ( $ this -> fields ) > 0 ) { if ( $ this -> method == 'GET' ) { $ url = $ this -> options [ CURLOPT_URL ] . '?' . $ this -> getQuery ( ) ; $ this -> setOption ( CURLOPT_URL , $ url ) ; } else { if ( isset ( $ this -> requestHeaders [ 'Content-Type' ] ) && ( $ this -> requestHeaders [ 'Content-Type' ] != 'multipart/form-data' ) ) { $ this -> setOption ( CURLOPT_POSTFIELDS , $ this -> getQuery ( ) ) ; $ this -> setRequestHeader ( 'Content-Length' , $ this -> getQueryLength ( ) ) ; } else { $ this -> setOption ( CURLOPT_POSTFIELDS , $ this -> fields ) ; } $ this -> setOption ( CURLOPT_POSTFIELDS , $ this -> fields ) ; $ this -> setOption ( CURLOPT_URL , $ url ) ; } } if ( $ this -> hasRequestHeaders ( ) ) { foreach ( $ this -> requestHeaders as $ header => $ value ) { $ headers [ ] = $ header . ': ' . $ value ; } $ this -> setOption ( CURLOPT_HTTPHEADER , $ headers ) ; } $ this -> response = curl_exec ( $ this -> resource ) ; if ( $ this -> response === false ) { $ this -> throwError ( 'Error: ' . curl_errno ( $ this -> resource ) . ' => ' . curl_error ( $ this -> resource ) . '.' ) ; } return $ this ; }
Create and open cURL resource.

@since 3.0.0

@return object
Create and open cURL resource .