Perform a GET request for the specified resource.

@param  string $resource
@param  string $body
@return \GuzzleHttp\Psr7\Response
16220
public function get($resource, $body = null, $params = [])
    {
        return $this->send($this->prepare('GET', $resource, $body, $params));
    }
583320
public function handle(string $method, $body = false, $uriAppend = false, array $queryParams = [])
    {
        $client   = $this->createElasticClient();
        $param    = $queryParams[0];
        $endPoint = "search";

        if (is_a($param, Search::class)) {
            $endPoint    = "search";
            $queryParams = $param->getParams();

        } elseif (is_a($param, MSearch::class)) {
            $endPoint    = "msearch";
            $queryParams = $param->getParams();
        }

        try {
            $elasticData = $client->{$endPoint}($queryParams);

            if ($client->transport->getLastConnection()) {
                $elasticData['debug'] = $client->transport->getLastConnection()->getLastRequestInfo();
            }

            if ($endPoint == 'msearch') {
                foreach ($elasticData['responses'] as $key => $responseItem) {
                    $responseItem['debug'] = $elasticData['debug'];
                    $response[]            = new Response($responseItem);
                }
            } else {
                $response = new Response($elasticData, $queryParams['body']['size'] ?? 0, $queryParams['body']['from'] ?? 0);
            }
        } catch (\Exception $ex) {
            $error = json_decode($ex->getMessage());
            throw new \Exception($error->error->reason ?? $ex->getMessage());
        }

        return $response;
    }
591939
protected function getServiceResponse($resource)
    {
        $response = $this->sendRequest('GET', $this->getServiceUrl($resource));
        $decodedResponseBody = $this->getDecodedBody($response->getBody());

        return $decodedResponseBody;
    }
242461
private function toPsr7Response(Response $response, ResourceObject $resourceObject)
    {
        $bodyString = (string) $resourceObject;
        /** @var $response Response */
        $response = $response->withStatus($resourceObject->code);
        foreach ($resourceObject->headers as $name => $value) {
            $response = $response->withHeader($name, $value);
        }
        $stream = $this->render->toStream($bodyString);
        $response = $response->withBody(new Stream($stream));

        return $response;
    }
112937
protected function getResponse(array $headers, $body)
    {
        // Create the response object.
        $return = new Response();

        // Set the body for the response.
        $return->getBody()->write($body);

        $return->getBody()->rewind();

        // Get the response code from the first offset of the response headers.
        preg_match('/[0-9]{3}/', array_shift($headers), $matches);
        $code = $matches[0];

        if (is_numeric($code)) {
            $return = $return->withStatus($code);
        } elseif (!$this->getOption('allow_empty_status_code', false)) {
            // No valid response code was detected.
            throw new \UnexpectedValueException('No HTTP response code found.');
        }
        // Add the response headers to the response object.
        foreach ($headers as $header) {
            $pos = strpos($header, ':');

            $return = $return->withHeader(trim(substr($header, 0, $pos)), trim(substr($header, ($pos + 1))));
        }

        return $return;
    }
374786
public function get($request, $base = 'http://loripsum.net/api/')
    {
        $uri = $base . ltrim($request, '/');

        return $this->client->get($uri, ['timeout' => 10])->getBody();
    }
1300997
public function get($resource = null, $data = array())
    {
        return $this->call($resource, AnHttpRequest::GET, $data);
    }
708656
private function getResponse($method, $path, $body = null, $headers = [])
    {
        $allHeaders = array_merge($this->getAuthorizationHeader(), $headers);
        $uri = $path;

        $request = new Request($method, $uri, $allHeaders, $body);

        return $this->guzzle->send($request);
    }
149770
public function get($resource, array $query = [])
    {
        $exec = $this->execute(Method::$HTTP_GET, $resource, ['query' => $query]);

        return $exec;
    }
223975
function get($resource, $query = array(), $headers = array()) {
        $url = $this->build_url($resource, $query);
        $result = $this->client->get($url, [
            'headers' => array_merge([
                'Authorization' => $this->getBearer()
            ], $headers)
        ])->json();
        return $result;
    }
202652
public function makeApiRequest($resource, array $params = array(), $method = 'GET')
    {

        $uri = $this->requestUri . '/' . ltrim($resource, '/');

        if ($this->hasValidToken()) {
            $params['oauth_token'] = $this->token;
        } else {
            $params['client_id'] = $this->clientId;
            $params['client_secret'] = $this->clientSecret;
        }

        // apply a dated "version"
        $params['v'] = $this->dateVerified->format('Ymd');

        switch ($method) {
            case 'GET':
                $response = json_decode($this->httpClient->get($uri, $params));
                break;
            case 'POST':
                $response = json_decode($this->httpClient->post($uri, $params));
                break;
            default:
                throw new \RuntimeException('Currently only HTTP methods "GET" and "POST" are supported.');
        }

        //TODO check headers for api request limit

        if (isset($response->meta)) {

            if (isset($response->meta->code)
                && $response->meta->code != 200
            ) {
                //TODO handle case
            }

            if (isset($response->meta->notifications)
                && is_array($response->meta->notifications)
                && count($response->meta->notifications)
            ) {

                //TODO handle notifications

            }

        }

        return $response->response;

    }
154856
protected function instance(string $body, int $status = 200, array $headers = []) : Response
    {
        $response = new Response('php://memory', $status, $headers);
        $response->getBody()->write($body);

        return $response;
    }
769876
public function httpRequest(
        string $method, string $uri, array $headers = [], array $body = []): EsiResponse
    {

        // Include some basic headers to those already passed in. Everything
        // is considered to be Json.
        $headers = array_merge($headers, [
            'Accept'       => 'application/json',
            'Content-Type' => 'application/json',
            'User-Agent'   => 'Eseye/' . Eseye::VERSION . '/' .
                Configuration::getInstance()->http_user_agent,
        ]);

        // Add some debug logging and start measuring how long the request took.
        $this->logger->debug('Making ' . $method . ' request to ' . $uri);
        $start = microtime(true);

        // Json encode the body if it has data, else just null it
        if (count($body) > 0)
            $body = json_encode($body);
        else
            $body = null;

        try {

            // Make the _actual_ request to ESI
            $response = $this->getClient()->send(
                new Request($method, $uri, $headers, $body));

        } catch (ClientException | ServerException $e) {

            // Log the event as failed
            $this->logger->error('[http ' . $e->getResponse()->getStatusCode() . ', ' .
                strtolower($e->getResponse()->getReasonPhrase()) . '] ' .
                $method . ' -> ' . $this->stripRefreshTokenValue($uri) . ' [t/e: ' .
                number_format(microtime(true) - $start, 2) . 's/' .
                implode(' ', $e->getResponse()->getHeader('X-Esi-Error-Limit-Remain')) . ']'
            );

            // Grab the body from the StreamInterface intance.
            $responseBody = $e->getResponse()->getBody()->getContents();

            // For debugging purposes, log the response body
            $this->logger->debug('Request for ' . $method . ' -> ' . $uri . ' failed. Response body was: ' .
                $responseBody);

            // Raise the exception that should be handled by the caller
            throw new RequestFailedException($e, $this->makeEsiResponse(
                $responseBody,
                $e->getResponse()->getHeaders(),
                'now',
                $e->getResponse()->getStatusCode())
            );
        }

        // Log the successful request.
        $this->logger->log('[http ' . $response->getStatusCode() . ', ' .
            strtolower($response->getReasonPhrase()) . '] ' .
            $method . ' -> ' . $this->stripRefreshTokenValue($uri) . ' [t/e: ' .
            number_format(microtime(true) - $start, 2) . 's/' .
            implode(' ', $response->getHeader('X-Esi-Error-Limit-Remain')) . ']'
        );

        // Return a container response that can be parsed.
        return $this->makeEsiResponse(
            $response->getBody()->getContents(),
            $response->getHeaders(),
            $response->hasHeader('Expires') ? $response->getHeader('Expires')[0] : 'now',
            $response->getStatusCode()
        );
    }
522091
public function request(string $path, array $params = null, string $method = null, $body = null, array $headers = null):ResponseInterface{
		$method = $method ?? 'GET';
		$params = $this->requestParams($path, $params ?? [], $body ?? []);

		if($method === 'POST'){
			$body   = $params;
			$params = [];
		}

#		return parent::request('', $params, $method, $body, $headers);

		$request = $this->requestFactory
			->createRequest($method, Psr7\merge_query($this->apiURL, $params));

		foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
			$request = $request->withAddedHeader($header, $value);
		}

		if($method === 'POST'){
			$request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded');
			$body    = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738));
			$request = $request->withBody($body);
		}

		return $this->http->sendRequest($request);
	}
1364722
private function request($method, $uri, $body = array())
    {
        try {
            $res = $this->client->request($method, $uri, $body);
            return json_decode($res->getBody());
        } catch(RequestException $e){
            $res = VariableUtil::json2Array(
                json_decode($e->getResponse()->getBody()->getContents())[0]
            );
            /*
             * If the session expired, then we must request a new token with the
             * refresh token.
             */
            if(isset($res['errorCode']) && $res['errorCode'] == 'INVALID_SESSION_ID'){
                $this->refreshToken($method, $uri, $body);
            } else {
                throw new ExternalApiException($e->getMessage(), $e->getCode(), $e);
            }
        }
    }
891582
protected function makeHttpRequest($url, $method, $headers, $body = null) {
    $request_headers = array_merge($headers, self::$api_version_header);

    $result = $this->doHttpRequest($url,
                                   $method,
                                   $request_headers,
                                   $body);

    if ($result === false) {
      return false;
    }

    return [
      'status_code' => $result['status_code'],
      'headers' => $result['headers'],
      'body' => $result['body'],
    ];
  }
1318072
public function body($body)
    {
        if ($body instanceof ReadableStreamInterface) {
            return new ReadableBodyStream($body);
        }

        return \RingCentral\Psr7\stream_for($body);
    }