Fires a request to the API
@param  string   $method HTTP Verb
@param  string   $url    Relative URL for the request
@param  array $data Data to be passed along the request
@return array Response data in array format. Not meant
to be used directly
552080
public function request($method, $url, $data = array())
    {
        $url = Api::getFullUrl($url);

        $hooks = new Requests_Hooks();

        $hooks->register('curl.before_send', array($this, 'setCurlSslOpts'));

        $options = array(
            'auth' => array(Api::getKey(), Api::getSecret()),
            'hook' => $hooks,
            'timeout' => 60,
        );

        $headers = $this->getRequestHeaders();

        $response = Requests::request($url, $headers, $data, $method, $options);

        $this->checkErrors($response);

        return json_decode($response->body, true);
    }
63551
protected function doRequest($method, $apiMethod, array $data = [])
    {
        $url = $this->config['endpoint'] . $apiMethod;
        $data = $this->mergeData($this->createAuthData(), $data);

        $response = $this->getGuzzleClient()->request($method, $url, ['json' => $data]);
        $responseContent = \GuzzleHttp\json_decode($response->getBody());

        if (!property_exists($responseContent, 'success') || !$responseContent->success) {
            throw new InvalidRequestException($method, $url, $data, $response);
        }

        return $responseContent;
    }
69131
public function request($method, $url, $data = null)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
            "Content-Type: application/json",
            "Authorization: {$this->public_key},{$this->secret_key}"
        ));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_URL, $this->api_url . $url);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);

        if ($data !== null) {
            curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
        }

        $response = curl_exec($curl);

        if (curl_errno($curl)) {
            throw new Error('Curl error: ' . curl_error($curl));
        }
        $info = curl_getinfo($curl);
        if ($info['http_code'] != 200) {
            throw new Error('API responded with wrong status code (' . $info['http_code'] . ')', json_decode($response));
        }

        return $response;
    }
1114913
protected function request($method, $relativeUrl, $data = null)
    {
        $request = new Request();

        $response = $request->request($method, $relativeUrl, $data);

        if ((isset($response['entity'])) and
            ($response['entity'] == $this->getEntity()))
        {
            $this->fill($response);

            return $this;
        }
        else
        {
            return static::buildEntity($response);
        }
    }
804247
protected function sendRequest($method, $url, $data = [], $headers = [])
    {
        $this->addRequestSourceHeader($headers);
        $data['http_errors'] = false;
        $data['headers'] = $headers;
        $response = $this->http_client->request($method, $url, $data);

        return $response;
    }
1085662
public function request(string $url, string $method = 'GET', array $options = [], $returnRaw = false)
    {
        if (empty($this->middlewares)) {
            $this->registerHttpMiddlewares();
        }

        $response = $this->performRequest($url, $method, $options);

        return $returnRaw ? $response : $this->castResponseToType($response, $this->app->config->get('response_type'));
    }
933351
public static function post($url, $data = [], $method = 'POST')
    {
        $ch = curl_init();

        if ( ! empty($data)) {
            $data = http_build_query($data);
        }
        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output

        $result = curl_exec($ch);
        
        curl_close($ch);

        if (false !== $result) {
            $result = json_decode($result);
            
        } else {
            throw new \Exception('Error during making request');
        }

        return $result;
    }
989541
private function request($url, $params = [], $method = 'GET')
    {
        // Set URL & Header
        curl_setopt($this->curl, CURLOPT_URL, $this->url . $url);
        curl_setopt($this->curl, CURLOPT_HTTPHEADER, array());

        //Add post vars
        if($method == 'POST')
        {
            curl_setopt($this->curl, CURLOPT_POST, count($params));
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, $params);
        }

        //Get result
        $result = curl_exec($this->curl);
        if($result === false)
            throw new \Exception('CURL error: ' . curl_error($this->curl));

        // decode results
        $result = json_decode($result, true);

        if(!is_array($result) || json_last_error())
            throw new \Exception('JSON decode error');

        return $result;

    }
517613
protected function sendRequest($url, array $params, $method)
    {
        $method = strtolower($method);
        $options = [
            CURLOPT_RETURNTRANSFER => true,
        ];

        if (self::REQUEST_METHOD_GET === $method) {
            $url .= '?' . http_build_query($params);
        } else {
            $options[CURLOPT_POST] = true;
            $options[CURLOPT_POSTFIELDS] = http_build_query($params);
        }

        $ch = curl_init($url);
        curl_setopt_array($ch, $options);
        $response = curl_exec($ch);

        if (!$response) {
            throw new \RuntimeException('cURL: ' . curl_error($ch), curl_errno($ch));
        }
        curl_close($ch);

        return $response;
    }
703298
private function _request($urn, array $data = [])
    {
        list($method, $url) = $this->_authLink($urn, $data);
        list($code, $json) = Http::basicRequest($method, $url, $this->_clientAuth, $data);
        return $json;
    }
1061473
public function sendRequest($url = '', $data = [], $method = 'GET', $magic = 'cURL')
    {
        try {
            $request                  = new MyRequests();
            $request->debugStatus     = $this->DEBUG;
            $request->debugLevel      = $this->debugLevel;
            $request->debugLoggerPath = $this->loggerPath;
            $request->__construct();
            $result = $request->sendRequest($url, $data, $method);

            return $result;
        }
        catch (\Exception $e) {
            $message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
            if (function_exists('log_message')) {
                log_message('error', $message);
            }

            return $message;
        }
    }
792168
private function send($method, $url, array $data = [], array $headers = [], $cacheMinutes = 0)
    {
        $method = strtolower($method);

        try
        {
            return $this->courier->$method($url, $data, $headers, $cacheMinutes);
        }
        catch (HttpRequestException $exception)
        {
            $response = $exception->response();

            if ($response->getResponseType() == 'application/json')
            {
                $response = $response->toArray();
                $error = sprintf('Twitter Error: %s (Error %d)', $response['errors'][0]['message'], $response['errors'][0]['code']);
            }
            else
            {
                $error = sprintf('HTTP Error: %s (Error %d)', $exception->getMessage(), $exception->getCode());
            }

            throw new TwitterException($error);
        }
    }
142651
protected function apiGet($url, $data = array())
    {
        if (!empty($data)) {
            $url = $url . "?" . http_build_query($data);
        }

        $response = $this->apiClient->get($url);

        return $this->processResponse($response);
    }
1354459
protected function _doRequest($method, $url, $data, $options)
    {
        $request = $this->_createRequest(
            $method,
            $url,
            $data,
            $options
        );

        return $this->send($request, $options);
    }
338033
public function makeRequest($url, $method = 'GET')
    {
        try {
            [$url, $parameters] = $this->getRequestUrlAndParameters($url, $method === 'GET');
            return $this->response = $this->client->request($method, $url, $parameters);
        } catch (RequestException $e) {
            $this->printErrorMessage(Psr7\str($e->getRequest()), false);
            if ($e->hasResponse()) {
                $this->response = $e->getResponse();
                $this->printErrorMessage(Psr7\str($e->getResponse()), false);
            }
        }
        return false;
    }
271119
public function request($method, $uri, array $data = array())
    {
        $path = $this->path() . '/' . trim($uri, '/');

        $session = curl_init();

        // Curious as why i have to do this
        if ($method === 'PUT') {
            curl_setopt($session, CURLOPT_POSTFIELDS, http_build_query($data));
        } else {
            $path .= '?' . http_build_query($data);
        }

        curl_setopt($session, CURLOPT_HEADER, true);
        curl_setopt($session, CURLOPT_HTTPHEADER, $this->defaultHeaders());
        curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($session, CURLOPT_POST, $method !== 'GET');

        curl_setopt($session, CURLOPT_URL, $path);
        curl_setopt($session, CURLOPT_CUSTOMREQUEST, $method);
        $response = curl_exec($session);
        $statusCode = curl_getinfo($session, CURLINFO_HTTP_CODE);
        $headerSize = curl_getinfo($session, CURLINFO_HEADER_SIZE);
        $body = substr($response, $headerSize);

        if ($statusCode !== 200) {
            throw new InvalidRequest($body);
        }

        curl_close($session);

        return json_decode($body, true);
    }
236843
public function api(string $method, string $endpoint, array $data = []): array
    {
        $endpoint = '/' . ltrim($endpoint, '/'); // Ensure leading slash is present
        return $this->api->call($method, $endpoint, $data);
    }