PHP code example of scrnr / weather
1. Go to this page and download the library: Download scrnr/weather library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
scrnr / weather example snippets
use Scrnr\Weather\Weather;
Weather::setToken('YOUR_TOKEN');
$forecast = Weather::getWeather('CITY_NAME', 'UNITS');
if ($forecast === false) {
$errors = Weather::getErrors();
}
Array
(
[today] => Array
(
[sunrise] => 05:09
[sunset] => 20:43
[date] => 27 April
[description] => Overcast clouds
[temp] => 5
[feelsLike] => 1
[pressure] => 755 mm Hg
[humidity] => 90%
[cityName] => Saint Petersburg
[visibility] => more than 10 km
[wind] => Array
(
[speed] => 7 m/s
[direction] => East
)
[isNight] => false
[icon] => http://openweathermap.org/img/wn/[email protected]
[tempMin] => 4
)
[fourDays] => Array
(
[0] => Array
(
[date] => 28 April
[icon] => http://openweathermap.org/img/wn/[email protected]
[max] => 7
[min] => 3
)
[1] => Array
(
[date] => 29 April
[icon] => http://openweathermap.org/img/wn/[email protected]
[max] => 4
[min] => 4
)
[2] => Array
(
[date] => 30 April
[icon] => http://openweathermap.org/img/wn/[email protected]
[max] => 7
[min] => 4
)
[3] => Array
(
[date] => 01 May
[icon] => http://openweathermap.org/img/wn/[email protected]
[max] => 7
[min] => 2
)
)
)