Sailthru_Client::httpRequest PHP Method

httpRequest() protected method

Perform an HTTP request, checking for curl extension support
protected httpRequest ( $action, array $data, string $method = 'POST', array $options = [] ) : string
$action
$data array
$method string
$options array
return string
    protected function httpRequest($action, $data, $method = 'POST', $options = [])
    {
        $response = $this->{$this->http_request_type}($action, $data, $method, $options);
        $json = json_decode($response, true);
        if ($json === NULL) {
            throw new Sailthru_Client_Exception("Response: {$response} is not a valid JSON", Sailthru_Client_Exception::CODE_RESPONSE_INVALID);
        }
        if (isset($json['error'])) {
            throw new Sailthru_Client_Exception($json['errormsg'], $json['error']);
        }
        return $json;
    }