1. Go to this page and download the library: Download dwr/open-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/ */
dwr / open-weather example snippets
// errors reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
g api key in environment variable: getenv('OPEN_WEATHER_API_KEY');
$openWeatherConfig = new Configuration($apiKey);
$openWeather = new OpenWeather('Weather', $openWeatherConfig);
$weather = $openWeather->getByCityName('London');
var_dump($weather);
// errors reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ng api key in environment variable.
//$apiKey = getenv('OPEN_WEATHER_API_KEY');
$openWeatherConfig = new Configuration($apiKey);
$openWeather = new OpenWeather('Forecast', $openWeatherConfig);
$forecast = $openWeather->getByCityName('London');
var_dump($forecast);
use Dwr\OpenWeather\Configuration;
use Dwr\OpenWeather\OpenWeather;
$apiKey = YOURS-API-KEY;
//Consider keeping api key in environment variable.
//$apiKey = getenv('OPEN_WEATHER_API_KEY');
$openWeatherConfig = new Configuration($apiKey);
//CONFIGURATION DwrOpenWeather
$openWeatherConfig->setBaseUri(NEW-BASE-URI);
$openWeatherConfig->setVersion(NEW-API-VERSION);
$openWeatherConfig->setTimeout(NEW-TIMEOUT);
$openWeatherConfig->setHttpClient(NEW-HTTP-CLIENT); //Has to implement GuzzleHttp\ClientInterface
$openWeatherConfig->setApiKey(NEW-API-URI);
$openWeather = new OpenWeather('Weather', $openWeatherConfig);
bash
$ php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.