PHP code example of owenandrews / willyweather-php

1. Go to this page and download the library: Download owenandrews/willyweather-php 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/ */

    

owenandrews / willyweather-php example snippets


use WillyWeather\Client;

$willyWeather = new Client('<API-KEY>');
$sydney = $willyWeather->location(4950);
$sydney->getName();

use WillyWeather\Client;

$willyWeather = new Client('<API-KEY>');
$sydney = $willyWeather->location(4950);
$sydney->getForecasts();
$sydney->getObservational();

use WillyWeather\Client;

$willyWeather = new Client('<API-KEY>');
$sydney = $willyWeather->location(4950);
$sydney->getForecasts(["forecasts" => ["temperature", "wind", "rainfallprobability"], "days" => 3]);

use WillyWeather\Client;

$willyWeather = new Client('<API-KEY>');
$sydney = $willyWeather->location(4950, ["forecasts" => ["temperature", "wind", "rainfallprobability"], "days" => 3, "observational" => true]);
$sydney->getForecasts();
$sydney->getObservational();

use WillyWeather\Client;

$willyWeather = new Client('<API-KEY>');
$sydney = $willyWeather->searchByQuery("Sydney")[0];

use WillyWeather\Client;

$willyWeather = new Client('<API-KEY>');
$mackenziesBay = $willyWeather->searchByCoordinates(["lat" => -33.8996141, "lng" => 151.272962])[0];

use WillyWeather\Client;

$willyWeather = new Client('<API-KEY>', '/tmp/');
bash
composer