PHP code example of thomasboom89 / openweathermap-one-call-api

1. Go to this page and download the library: Download thomasboom89/openweathermap-one-call-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/ */

    

thomasboom89 / openweathermap-one-call-api example snippets


$httpClient  = new Client();
$httpFactory = new HttpFactory();
$owmoca      = new OneCallApi("YOUR-API-KEY", $httpClient, $httpFactory);

// Optional use caching interface
$pool        = new ArrayAdapter();
$cache       = new Psr16Cache($pool);
$owmoca      = new OneCallApi("YOUR-API-KEY", $httpClient, $httpFactory, $cache, 240);

// lat , lon , language , unitsystem
try {
    $forecast = $owmoca->getForecast(-78.944450, 19.458971, OneCallApi\Language::German, OneCallApi\Unit::Metric);
 } catch (Exception $exception){
    // handle exception
 }

var_dump($forecast);