PHP code example of lfischer / open-weather-map-api
1. Go to this page and download the library: Download lfischer/open-weather-map-api 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/ */
lfischer / open-weather-map-api example snippets
use lfischer\openWeatherMap\API;
// Get weather data by a city and (optional) country name.
$weather = (new API('<API-key here>'))
->getCurrentWeather()
->byCityName('Dusseldorf,Germany');
// Get weather data by a "city ID".
$weather = (new API('<API-key here>'))
->getCurrentWeather()
->byCityId(524901);
// Get weather data by a city and (optional) country name.
use lfischer\openWeatherMap\API;
use lfischer\openWeatherMap\Parameter\Language;
use lfischer\openWeatherMap\Parameter\Mode;
use lfischer\openWeatherMap\Parameter\Unit;
$weather = (new API('<API-key here>'))
->getCurrentWeather()
->setMode(Mode::XML)
->setUnit(Unit::METRIC)
->setLanguage(Language::ENGLISH)
->byCityName('Dusseldorf,Germany');