App\services\RESTfulService::request PHP Method

request() public method

Make a request to the API.
public request ( string $verb, string $uri, boolean $appendKey = true, array $params = [] ) : object | string
$verb string The HTTP verb
$uri string The API URI (segment)
$appendKey boolean Whether to automatically append the API key into the URI. While it's usually the case, some services (like Last.fm) requires an "API signature" of the request. Appending an API key will break the request.
$params array An array of parameters
return object | string
    public function request($verb, $uri, $appendKey = true, array $params = [])
    {
        try {
            $body = (string) $this->getClient()->{$verb}($this->buildUrl($uri, $appendKey), ['form_params' => $params])->getBody();
            if ($this->responseFormat === 'json') {
                return json_decode($body);
            }
            if ($this->responseFormat === 'xml') {
                return simplexml_load_string($body);
            }
            return $body;
        } catch (ClientException $e) {
            return false;
        }
    }