Browse Source

don't crash with an invalid api key

main
Aaron Parecki 6 years ago
parent
commit
ab7506b66f
No known key found for this signature in database GPG Key ID: 276C2817346D6056
2 changed files with 4 additions and 1 deletions
  1. +1
    -1
      controllers/weather.php
  2. +3
    -0
      p3k/Weather.php

+ 1
- 1
controllers/weather.php View File

@ -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 {

+ 3
- 0
p3k/Weather.php View File

@ -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 = [

Loading…
Cancel
Save