public function request($method, $url, $params = null)
    {
        if (!$params) {
            $params = array();
        } else {
            $params = self::encodeObjects($params);
        }

        // Set request data if configured
        if (in_array('request', $this->config['dataResponse'])) {
            $this->state['request']['body'] = $params;
        }

        /*
         * Send request based on dataFormat. Format 'array'
         * is json_encoded and sent as json.
         */
        $this->debug_echo("\nRequest (".$this->config['dataFormat']."):\n");
        switch ($this->config['dataFormat']) {
            case 'array':
                // Set data method
                $this->state['method'] = $params['_method'];
                // Encode parameters
                $this->debug_print_r($params); 
                try {
                    $params = json_encode($params);
                } catch (Exception $e) {
                    $msg = 'JSON Encode Error - Invalid parameters: '.serialize($params);
                    throw new ApiException($msg, $this->state);
                }
                $this->debug_echo("\nRequest (json):\n");
                // Intentionally dropping into json case
            case 'json':
                $this->debug_echo($params); 
                // Generate absolute url
                $absUrl = $this->apiUrl($url, 'json');
                // Format params for curl request POSTFIELDS
                $params = array('json' => $params);
                // Send request
                $this->curlRequest(
                    $method,
                    $absUrl,
                    $params
                );
                // Process response
                $this->interpretResponseJSON();
                break;
            case 'xml':
                $this->debug_echo($params); 
                // Generate absolute url
                $absUrl = $this->apiUrl($url, 'xml');
                $this->debug_echo("\n\nURL:\n");
                $this->debug_print_r($absUrl);
                // Format params for curl request POSTFIELDS
                $params = 'xmlRequestString='.urlencode($params);
                // Send request
                $this->curlRequest(
                    $method,
                    $absUrl,
                    $params
                );
                // Process response
                $this->interpretResponseXML();
                break;
            default:
                $msg = 'Invalid data format: '.$this->config['dataFormat'];
                throw new ApiException($msg, $this->state);
        }

        return $this->formatResponse();
    }