diff --git a/controllers/weather.php b/controllers/weather.php index cb53298..7d1c377 100644 --- a/controllers/weather.php +++ b/controllers/weather.php @@ -16,7 +16,7 @@ $app->get('/api/weather', function() use($app) { } else { json_response($app, [ 'error' => 'not_found', - 'error_description' => 'No weather information was found for the requested location' + 'error_description' => 'No weather information was found for the requested location, or you used an invalid API key' ]); } } else { diff --git a/p3k/Weather.php b/p3k/Weather.php index c0cfc91..6fdef29 100644 --- a/p3k/Weather.php +++ b/p3k/Weather.php @@ -9,6 +9,9 @@ class Weather { $data = self::_fetch($lat, $lng, $key); if(!$data) return null; + if(!property_exists($data, 'current_observation')) + return null; + $current = $data->current_observation; $weather = [