Call http method

@param string $uri
@param string $method
@param array $data
486735
private function callHttpMethod($uri, $method, array $data = [])
    {
        $request = new Request();
        $request->setUri($uri);
        if (! empty($data)) {
            switch ($method) {
                case Request::METHOD_GET:
                    $request->setQuery(new Parameters($data));
                    break;
                case Request::METHOD_POST:
                case Request::METHOD_PUT:
                case Request::METHOD_PATCH:
                    $request->setContent(json_encode($data));
                    break;
            }
        }
        $request->setMethod($method);
        $request->getHeaders()->addHeaders($this->getDefaultHeaders());
        return json_decode($this->getHttpClient()->send($request)->getBody());
    }
695782
protected function _doRequest($method, $uri, $options)
    {
        // For Guzzle5 we cannot have any options that are not pre-defined,
        // so instead we put it in the config array
        if (isset($options[self::OPT_VIDEO_MANAGER_ID])) {
            $options['config'][self::OPT_VIDEO_MANAGER_ID] = $options[self::OPT_VIDEO_MANAGER_ID];
            unset($options[self::OPT_VIDEO_MANAGER_ID]);
        }

        $request = $this->httpClient->createRequest($method, $uri, $options);

        return $this->httpClient->send($request);
    }
582917
public function send($url, $method = 'GET', $data = [])
    {
        $method = strtolower($method);

        $settings = [
            'headers'  => array_merge([
                'Authorization' => 'Bearer ' . $this->getToken(),
                'Content-Type' => 'application/x-www-form-urlencoded',
            ], $this->getHeaders()),
        ];

        if ($method == 'post') {
            $settings['form_params'] = $data;
        }

        return $this->client
            ->$method($url, $settings);
    }
1169358
public static function run($url = null, $data = null, $method = 'GET') {
        if ($url) {
            if (is_string($data)) {
                $method = $data;
                $data   = null;
            }
            $method                 = strtoupper($method);
            $_SERVER['REQUEST_URI'] = $url;
            $query                  = @parse_url($url, PHP_URL_QUERY);
            if ($query) {
                $args = [];
                parse_str($query, $args);
                if ($args) {
                    if ($data) {
                        $data = array_merge($data, $args);
                    } else {
                        $data = $args;
                    }
                }
            }
            $_SERVER['REQUEST_METHOD'] = $method;
            if ($data) {
                if ($method == 'GET') {
                    $_SERVER['QUERY_STRING'] = http_build_query($data);
                }
                Request::getInstance()->addUserData($data);
            }

            $_SERVER['REQUEST_TIME'] = time();
        }
        if (!isset ($_SERVER ['REQUEST_URI'])) {
            Response::respond(500, 'Your web server did not provide REQUEST_URI, stop route request.');
        }

        if (!self::$app->router) {
            self::$app->router = Router::getRouter();
        }
        try {
            return self::$app->router->route();
        } catch (\Exception $e) {
            if (defined('DEBUG') && DEBUG < DEBUG_ERROR) {
                show_exception_page($e);
            } else {
                Response::respond(500, $e->getMessage());
            }
        }

        return false;
    }
49525
public function send($uri, $method, array $headers = [], $datas = [], array $files = [])
    {
        return $this->sendRequest($this->getConfiguration()->getMessageFactory()->createInternalRequest(
            $uri,
            $method,
            $this->getConfiguration()->getProtocolVersion(),
            $headers,
            $datas,
            $files
        ));
    }
754348
private function sendRequest($method, $url, $data = false)
    {
        $curlHandler = curl_init();
        curl_setopt($curlHandler, CURLOPT_HTTPHEADER, $this->formatUserAgentInfo());

        if ($method === 'POST') {
            curl_setopt($curlHandler, CURLOPT_POST, 1);

            if ($data) {
                curl_setopt($curlHandler, CURLOPT_POSTFIELDS, json_encode($data));
            }
        }

        if ($method === 'GET' && $data) {
            $url = sprintf("%s?%s", $url, http_build_query($data));
        }

        curl_setopt($curlHandler, CURLOPT_URL, $url);
        curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);

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

        $this->curlInfo = curl_getinfo($curlHandler);
        $httpCode = curl_getinfo($curlHandler)['http_code'];

        if ($httpCode >= 400) {
            throw new \Exception($this->json()['status'], $httpCode);
        }

        curl_close($curlHandler);

        return $this;
    }
1110228
public function doRequest($uri, $method = 'GET', $headers = array(), $body = NULL) {

    $in = NULL;
    if (!empty($body)) {
      // For whatever reason, CURL seems to want POST request data to be
      // a string, not a file handle. So we adjust. PUT, on the other hand,
      // needs to be in a file handle.
      if ($method == 'POST') {
        $in = $body;
      }
      else {
        // First we turn our body into a temp-backed buffer.
        $in = fopen('php://temp', 'wr', FALSE);
        fwrite($in, $body, strlen($body));
        rewind($in);
      }
    }
    return $this->handleDoRequest($uri, $method, $headers, $in);
    //return $this->handleDoRequest($uri, $method, $headers, $body);

  }
793112
public function execute($method, $url, array $data = [])
    {
        $client = new Client(['handler' => $this->handler]);

        return json_decode($client->request($method, $url, array_merge($data, self::$OPTIONS))->getBody());
    }
981783
protected function exec($method, $uri, $data, $content_type)
    {
        $connect = $this->getConnect($uri, $method, $content_type);
        if ($data) {
            $this->setData($connect, $data, $content_type);
        }

        $api_result = curl_exec($connect);
        $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE);
        $api_http_time = curl_getinfo($connect, CURLINFO_TOTAL_TIME);

        $response = array(
            "status" => $api_http_code,
            "total_time" => $api_http_time,
        );

        if ($content_type == "application/json") {
            $response["response"] = json_decode($api_result, true);
        } elseif ($content_type == "text/html") {
            $response["response"] = $api_result;
        }

        if ($response['status'] >= 400) {
            throw new Exception($response['response'], $response['status']);
        }

        curl_close($connect);

        return $response;
    }
909580
public function request($method, $url, array $data = [])
    {
        return $this->request->send($this->baseUrl.'/'.$url, $method, $data);
    }
1165300
public function send($url, $method = 'GET', $data = null, callable $callback = null)
    {
        $this->curl($url);
        $this->setDefaultOptions();

        if (is_array($this->options))
        {
            if (count($this->options) > 0)
            {
                foreach ($this->options as $key => $value)
                {
                    $this->setOption($key, $value);
                }
            }
        }

        if ($method !== self::GET)
        {
            $this->method($method);
        }

        if ($method === self::POST || $method === self::PUT || $method === self::DELETE)
        {
            $this->setOption(CURLOPT_POSTFIELDS, $data);
        }

        $response = $this->execute();

        if (!$response)
        {
            $this->error();
        }

        $this->getInfo();
        $this->close();

        if ( is_callable($callback) )
        {
            $callback($this->response, $this->info, $this->errors);
        }

        return $response;
    }
277892
public function requestAsync($method, $uri = null, array $options = [])
    {
        $options = $this->setRequestOptions($options);

        $query = parse_url($uri, PHP_URL_QUERY);
        if (!empty($query)) {
            $uri = substr($uri, 0, (strlen($query)+1) * -1);
            parse_str($query, $options['query']);
        }

        return parent::requestAsync($method, $uri, $options);
    }
884176
public function createRequest($method, $uri)
    {
        if (is_string($uri)) {
            $uri = (new UriFactory())->createUri($uri);
        }
        return new Request($method, $uri);
    }
488401
public function callSecure($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
    {
        $uri = $this->app['url']->secure(ltrim($uri, '/'));

        return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content);
    }
243541
private function send($method, $uri, $data, $type = 'json')
    {
        // Make the Request to Watson.
        $response = $this->request($method, $uri, [$type => $data]);
        // Request Failed.
        if ($response->getStatusCode() != 200) {
            // Throw Watson Bridge Exception.
            $this->failedRequest($response);
        }

        // We return response.
        return $response;
    }
230229
public function execute($method, $resource, array $data = [])
    {
        $request = new Request($this->handler);
        $dataResource = $request->execute($method, $this->makeUrl($resource), array_merge($data, [
            'headers' => [
                'Authorization' => sprintf('Basic %s', base64_encode($this->token . ':' . ''))
            ]
        ]));

        return $dataResource;
    }
1256833
public function request($method, $url, array $data = array(), array $extra = array())
    {
        switch (strtoupper($method)) {
            case 'POST':
                return $this->post($url, $data, $extra);
            case 'GET':
                return $this->get($url, $data, $extra);
            case 'PATCH':
                return $this->patch($url, $data, $extra);
            case 'HEAD':
                return $this->head($url, $data, $extra);
            case 'PUT':
                return $this->put($url, $data, $extra);
            case 'DELETE':
                return $this->delete($url, $data, $extra);
            default:
                throw new UnexpectedValueException(sprintf('Unsupported or unknown HTTP method provided "%s"', $method));
        }
    }