]> git.mxchange.org Git - friendica-addons.git/blob - curweather/vendor/cmfcmf/openweathermap-php-api/README.md
added composer.json and needed libs
[friendica-addons.git] / curweather / vendor / cmfcmf / openweathermap-php-api / README.md
1 OpenWeatherMap-PHP-Api
2 ======================
3 A php api to parse weather data from [OpenWeatherMap.org](http://www.OpenWeatherMap.org). This api tries to normalise and abstract the data and remove inconsistencies.
4
5 [![Build Status](https://travis-ci.org/cmfcmf/OpenWeatherMap-PHP-Api.png?branch=master)](https://travis-ci.org/cmfcmf/OpenWeatherMap-PHP-Api)[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/badges/quality-score.png?s=f31ca08aa8896416cf162403d34362f0a5da0966)](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/)[![Code Coverage](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/badges/coverage.png?s=65153e7cfb13e050d734c645e38f2dd7ea7a6860)](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/)
6 [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0addfb24-e2b4-4feb-848e-86b2078ca104/big.png)](https://insight.sensiolabs.com/projects/0addfb24-e2b4-4feb-848e-86b2078ca104)
7 -----------
8
9 For example code and how to use this api, please take a look into `Examples_*.php` files and run them in your browser.
10 - `Examples_Current.php` Shows how to receive the current weather.
11 - `Examples_Forecast.php` Shows how to receive weather forecasts.
12 - [*NEW*] `Examples_History.php` Shows how to receive weather history.
13 - `Examples_Cache.php` Shows how to implement a cache.
14
15 **Notice:** This api is not made by OpenWeatherMap, nor their official php api.
16
17 Contribute!
18 ===========
19 I'm very happy if you open **pull requests** or **issues** to help making this API **more awesome**.
20
21 Installation
22 ============
23 This library can be found on [Packagist](https://packagist.org/packages/cmfcmf/openweathermap-php-api).
24 The recommended way to install this is through [composer](http://getcomposer.org).
25
26 Edit your `composer.json` and add:
27
28 ```json
29 {
30     "require": {
31         "cmfcmf/openweathermap-php-api": "~2.0"
32     }
33 }
34 ```
35
36 And install dependencies:
37
38 ```bash
39 $ curl -sS https://getcomposer.org/installer | php
40 $ php composer.phar install
41 ```
42
43
44 Example call
45 ============
46 ```php
47 <?php
48 use Cmfcmf\OpenWeatherMap;
49 use Cmfcmf\OpenWeatherMap\Exception as OWMException;
50
51 // Must point to composer's autoload file.
52 require('vendor/autoload.php');
53
54 // Language of data (try your own language here!):
55 $lang = 'de';
56
57 // Units (can be 'metric' or 'imperial' [default]):
58 $units = 'metric';
59
60 // Get OpenWeatherMap object. Don't use caching (take a look into Example_Cache.php to see how it works).
61 $owm = new OpenWeatherMap();
62
63 try {
64     $weather = $owm->getWeather('Berlin', $units, $lang);
65 } catch(OWMException $e) {
66     echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
67     echo "<br />\n";
68 } catch(\Exception $e) {
69     echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
70     echo "<br />\n";
71 }
72
73 echo $weather->temperature;
74 ```
75
76 License
77 =======
78 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.
79
80 **Please check out the following links to read about the usage policies and the license of OpenWeatherMap before using the service.**
81 - [OpenWeatherMap.org](http://www.OpenWeatherMap.org)
82 - [OpenWeatherMap.org/terms](http://www.OpenWeatherMap.org/terms)
83 - [OpenWeatherMap.org/appid](http://www.OpenWeatherMap.org/appid)