client = service('curlrequest', options: [ // 'timeout' => 10.0, // 'connect_timeout' => 150, // 'debug' => false, // 'verify' => false, // ]); } public function get(string $path, array $parameters = [], array $headers = []): array { $path = self::BASE_URL.$path.'?api_key=49a4c5ff00d832668aa505feaf197955'; $headers['Authorization'] = 'Bearer 49a4c5ff00d832668aa505feaf197955'; $headers['accept'] = 'application/json'; try { $r = Http::withHeaders($headers)->get($path); // $r = $this->client->request('GET', $path, [ // 'headers' => $headers // ]); } catch (\Throwable $e) { var_dump($e->getMessage()); die; } return $this->decodeResponse( $r ); } private function decodeResponse($response) { try { if ($response->body()) { return json_decode($response->body(), true, 512, JSON_THROW_ON_ERROR); } return []; } catch (JsonException $e) { throw new UnexpectedResponseException( sprintf( 'Unable to decode response with body "%s", %s.', (string)$response->body(), json_last_error_msg() ), $response->status(), $e ); } } }