OpenWeatherMap PHP API
======================
A php API to retrieve and parse global weather data from
[OpenWeatherMap.org](http://www.OpenWeatherMap.org).
This library aims to normalise the provided data and remove some inconsistencies.
This library is neither maintained by OpenWeatherMap nor their official PHP API.
[](https://travis-ci.org/cmfcmf/OpenWeatherMap-PHP-Api)
[](https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/master/LICENSE)
[](https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/releases)
[](https://codecov.io/gh/cmfcmf/OpenWeatherMap-PHP-Api)
[](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/)
[](https://insight.sensiolabs.com/projects/0addfb24-e2b4-4feb-848e-86b2078ca104)
Installation
============
This library can be found on [Packagist](https://packagist.org/packages/cmfcmf/openweathermap-php-api).
The recommended way to install and use it is through [Composer](http://getcomposer.org).
composer require "cmfcmf/openweathermap-php-api"
Example call
============
```php
getWeather('Berlin', $units, $lang);
} catch(OWMException $e) {
echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
} catch(\Exception $e) {
echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
}
echo $weather->temperature;
```
For more example code and instructions on how to use this library, please take
a look into the `Examples` folder. Make sure to get an API Key from
http://home.openweathermap.org/ and put it into `Examples/ApiKey.ini`.
- `CurrentWeather.php` Shows how to receive the current weather.
- `WeatherForecast.php` Shows how to receive weather forecasts.
- `WeatherHistory.php` Shows how to receive weather history.
- `Cache.php` Shows how to implement and use a cache.
Contributing
============
I'm happy about every **pull request** or **issue** you find and open to help
make this API **more awesome**.
You can use [Vagrant](https://vagrantup.com) to kick-start your development.
Simply run `vagrant up` and `vagrant ssh` to start a PHP VM with all
dependencies included.
## Support me
If you like my work, I'd really appreciate you buying me a coffee.
Your donations help me put more time into Open-Source software development.
License
=======
MIT — Please see the [LICENSE file](https://github.com/Cmfcmf/OpenWeatherMap-PHP-Api/blob/master/LICENSE)
distributed with this source code for further information regarding copyright and licensing.
**Please check out the following official links to read about the terms, pricing
and license of OpenWeatherMap before using the service:**
- [OpenWeatherMap.org/terms](http://OpenWeatherMap.org/terms)
- [OpenWeatherMap.org/appid](http://OpenWeatherMap.org/appid)