Longman\TelegramBot\Commands\UserCommands\WeatherCommand::getWeatherData PHP Méthode

getWeatherData() private méthode

Get weather data using HTTP request
private getWeatherData ( string $location ) : string
$location string
Résultat string
    private function getWeatherData($location)
    {
        $client = new Client(['base_uri' => $this->owm_api_base_uri]);
        $path = 'weather';
        $query = ['q' => $location, 'units' => 'metric', 'APPID' => trim($this->getConfig('owm_api_key'))];
        try {
            $response = $client->get($path, ['query' => $query]);
        } catch (RequestException $e) {
            TelegramLog::error($e->getMessage());
            return '';
        }
        return (string) $response->getBody();
    }