private function curlRequest($method, $absUrl, $params)
    {
        $result = array();
        $opts = array();
        $curl = curl_init();

        if ($method == 'post') {
            $opts[CURLOPT_POST] = 1;
            $opts[CURLOPT_POSTFIELDS] = $params;
        } else {
            throw new ApiException('Unsupported method '.$method, $this->state);
        }

        $absUrl = self::utf8($absUrl);
        $opts[CURLOPT_URL] = $absUrl;
        $opts[CURLOPT_RETURNTRANSFER] = true;
        $opts[CURLOPT_CONNECTTIMEOUT] = 20;
        $opts[CURLOPT_TIMEOUT] = 60;
        $opts[CURLOPT_HEADER] = true;
        $opts[CURLOPT_USERAGENT] = 'PHP SDK/1.0';

        // Apply options
        curl_setopt_array($curl, $opts);

        // Set request time if configured
        if (in_array('timeRequest', $this->config['dataResponse'])) {
            $this->state['request']['time'] = new \DateTime();
        }

        // Sent request
        $curl_result = curl_exec($curl);

        // Set response time if configured
        if (in_array('timeResponse', $this->config['dataResponse'])) {
            $this->state['response']['time'] = new \DateTime();
        }

        // Error handling
        if ($curl_result === false) {
            $errno = curl_errno($curl);
            $message = curl_error($curl);
            curl_close($curl);
            $this->handleCurlError($errno, $message);
        }

        // Parse code, headers, body from response
        $this->state['response']['code'] = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        $this->state['response']['headers'] = substr($curl_result, 0, $header_size);
        $this->state['response']['body_raw'] = substr($curl_result, $header_size);
        curl_close($curl);

        return $this->state;
    }
private function curlRequest($method, $absUrl, $params)
    {
        $result = array();
        $opts = array();
        $curl = curl_init();

        if ($method == 'post') {
            $opts[CURLOPT_POST] = 1;
            $opts[CURLOPT_POSTFIELDS] = $params;
        } else {
            throw new ApiException('Unsupported method '.$method, $this->state);
        }

        $absUrl = self::utf8($absUrl);
        $opts[CURLOPT_URL] = $absUrl;
        $opts[CURLOPT_RETURNTRANSFER] = true;
        $opts[CURLOPT_CONNECTTIMEOUT] = 20;
        $opts[CURLOPT_TIMEOUT] = 60;
        $opts[CURLOPT_HEADER] = true;
        $opts[CURLOPT_USERAGENT] = 'PHP SDK/1.0';

        // Apply options
        curl_setopt_array($curl, $opts);

        // Set request time if configured
        if (in_array('timeRequest', $this->config['dataResponse'])) {
            $this->state['request']['time'] = new \DateTime();
        }

        // Sent request
        $curl_result = curl_exec($curl);

        // Set response time if configured
        if (in_array('timeResponse', $this->config['dataResponse'])) {
            $this->state['response']['time'] = new \DateTime();
        }

        // Error handling
        if ($curl_result === false) {
            $errno = curl_errno($curl);
            $message = curl_error($curl);
            curl_close($curl);
            $this->handleCurlError($errno, $message);
        }

        // Parse code, headers, body from response
        $this->state['response']['code'] = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        $this->state['response']['headers'] = substr($curl_result, 0, $header_size);
        $this->state['response']['body_raw'] = substr($curl_result, $header_size);
        curl_close($curl);

        return $this->state;
    }
private function curlRequest ( $ method , $ absUrl , $ params ) { $ result = array ( ) ; $ opts = array ( ) ; $ curl = curl_init ( ) ; if ( $ method == 'post' ) { $ opts [ CURLOPT_POST ] = 1 ; $ opts [ CURLOPT_POSTFIELDS ] = $ params ; } else { throw new ApiException ( 'Unsupported method ' . $ method , $ this -> state ) ; } $ absUrl = self :: utf8 ( $ absUrl ) ; $ opts [ CURLOPT_URL ] = $ absUrl ; $ opts [ CURLOPT_RETURNTRANSFER ] = true ; $ opts [ CURLOPT_CONNECTTIMEOUT ] = 20 ; $ opts [ CURLOPT_TIMEOUT ] = 60 ; $ opts [ CURLOPT_HEADER ] = true ; $ opts [ CURLOPT_USERAGENT ] = 'PHP SDK/1.0' ; // Apply options curl_setopt_array ( $ curl , $ opts ) ; // Set request time if configured if ( in_array ( 'timeRequest' , $ this -> config [ 'dataResponse' ] ) ) { $ this -> state [ 'request' ] [ 'time' ] = new \ DateTime ( ) ; } // Sent request $ curl_result = curl_exec ( $ curl ) ; // Set response time if configured if ( in_array ( 'timeResponse' , $ this -> config [ 'dataResponse' ] ) ) { $ this -> state [ 'response' ] [ 'time' ] = new \ DateTime ( ) ; } // Error handling if ( $ curl_result === false ) { $ errno = curl_errno ( $ curl ) ; $ message = curl_error ( $ curl ) ; curl_close ( $ curl ) ; $ this -> handleCurlError ( $ errno , $ message ) ; } // Parse code, headers, body from response $ this -> state [ 'response' ] [ 'code' ] = curl_getinfo ( $ curl , CURLINFO_HTTP_CODE ) ; $ header_size = curl_getinfo ( $ curl , CURLINFO_HEADER_SIZE ) ; $ this -> state [ 'response' ] [ 'headers' ] = substr ( $ curl_result , 0 , $ header_size ) ; $ this -> state [ 'response' ] [ 'body_raw' ] = substr ( $ curl_result , $ header_size ) ; curl_close ( $ curl ) ; return $ this -> state ; }
Send a JSON or XML CURL request.

@param string $method HTTP method.
@param string $absUrl The absolute endpoint URL.
@param array|null $params API parameters.

@return mixed API response, code, headers.

@throws MyAllocator\phpsdk\src\Exception\ApiException
Send a JSON or XML CURL request .