1. Go to this page and download the library: Download previousnext/bom-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/ */
previousnext / bom-weather example snippets
$httpClient = new GuzzleHttp\Client(['base_uri' => 'http://www.bom.gov.au/']);
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$client = new BomClient($httpClient, $requestFactory, new NullLogger());
$forecast = $client->getForecast('IDN10031');
$issueTime = $forecast->getIssueTime();
$regions = $forecast->getRegions();
$metros = $forecast->getMetropolitanAreas();
$locations = $forecast->getLocations();
foreach ($locations as $location) {
$aac = $location->getAac();
$desc = $location->getDescription();
/** @var \BomWeather\Forecast\ForecastPeriod[] $periods */
$periods = $location->getForecastPeriods();
// Usually 7 days of forecast data.
foreach ($periods as $period) {
$date = $period->getStartTime();
$maxTemp = $period->getAirTempMaximum();
$precis = $period->getPrecis();
}
}
$httpClient = new GuzzleHttp\Client(['base_uri' => 'http://www.bom.gov.au/']);
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$client = new BomClient($httpClient, $requestFactory, new NullLogger());
$warning = $client->getWarning('IDN20400');
$issueTime = $warning->getIssueTime();
// Warning info contains the title and advice.
$warningInfo = $warning->getWarningInfo();
$title = $warningInfo->getWarningTitle();
$nextIssue = $warningInfo->getWarningNextIssue();
// Areas affected by the warning.
$regions = $warning->getRegions();
$coasts = $warning->getCoasts();
foreach ($regions as $region) {
$aac = $region->getAac();
$description = $region->getDescription();
}