@@ -9,32 +9,42 @@ PHP wrapper for Weatherbit.io API
99
1010` composer require attogram/weatherbit-api-wrapper `
1111
12+ * Get an API Key from: < https://www.weatherbit.io/ >
13+
1214## Example Usage
1315
1416``` php
1517<?php
1618
1719require('path/to/vendor/autoload.php');
1820
19- $weatherbit = new \Attogram\Weatherbit\Weatherbit();
20-
21- $weatherbit->setKey('YOUR-WEATHERBIT-API-KEY');
21+ try {
22+ $weatherbit = new \Attogram\Weatherbit\Weatherbit();
23+ $weatherbit->setKey('YOUR-WEATHERBIT-API-KEY');
24+ $weatherbit->setCity('Amsterdam');
25+ $weatherbit->setCountry('NL');
2226
23- $ weatherbit->setCity('Amsterdam');
27+ $currentWeather = $ weatherbit->getCurrent(); // Gets array of current weather data
2428
25- $ weatherbit->setCountry('NL');
29+ $forecastedWeather = $ weatherbit->getDailyForecast(15); // Gets array 15 day forecast
2630
27- $currentWeather = $weatherbit->getCurrent(); // Get current weather data
31+ } catch (Exception $exception) {
32+ exit('Error: ' . $exception->getMessage());
33+ }
2834
29- $forecastedWeather = $weatherbit->getDailyForecast(15); // Get 15 day forecast
35+ print "Current Weather:\n";
36+ print_r($currentWeather);
3037
38+ print "Forecasted Weather:\n";
39+ print_r($forecastedWeather);
3140
3241```
3342
3443* see [ public/test.php] ( public/test.php ) for an example web form
3544
3645## Links
3746
47+ * Github: < https://github.com/attogram/weatherbit-api-wrapper/ >
3848* Packagist: < https://packagist.org/packages/attogram/weatherbit-api-wrapper >
3949* CodeClimate: < https://codeclimate.com/github/attogram/weatherbit-api-wrapper >
4050* Travis CI: < https://travis-ci.org/attogram/weatherbit-api-wrapper >
0 commit comments