1. Go to this page and download the library: Download rubin/openweather 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/ */
rubin / openweather example snippets
$openWeatherApi = new \OpenWeather\OpenWeatherApi('{key}');
$openWeatherApi->setLanguage('ru');
$openWeatherApi = new \OpenWeather\OpenWeatherApi('{key}');
$output = new \Symfony\Component\Console\Output\StreamOutput(fopen('php://stdout', 'w'));
$table = new \Symfony\Component\Console\Helper\Table($output);
$table
->setHeaders(['Latitude', 'Longitude', 'Temperature', 'Weather'])
->setRows(array_map(function (\OpenWeather\GeoCoordinates $coordinates) use ($openWeatherApi) {
$current = $openWeatherApi->getCurrentWeather($coordinates);
return [
$coordinates->lat,
$coordinates->lon,
$current->main->temp,
$current->weather[0]->description
];
}, [
new \OpenWeather\GeoCoordinates(lon: 37.36, lat: 55.45),
new \OpenWeather\GeoCoordinates(lon: -66.159, lat: -68.2008),
new \OpenWeather\GeoCoordinates(lon: 147.794, lat: -31.358)
]));
$table->render();