1. Go to this page and download the library: Download kabudu/forecast-tools 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/ */
kabudu / forecast-tools example snippets
// The Castro
$latitude = 37.770452;
$longitude = -122.424923;
// Make request to the API for the current forecast
$forecast = new Forecast('YOUR_API_KEY_HERE');
$response = $forecast->getData($latitude, $longitude);
$currently = $response->getCurrently();
$time = date("H:i:s", $currently->getTime());
$temp = number_format($currently->getTemperature(), 1);
echo "Temperature in the Castro at $time: $temp℉<br />\n";
$data = $response->getRawData();
var_dump($data);
eads = 10;
$forecast = new Forecast('YOUR_API_KEY_HERE', $threads);
// The Castro
$latitude = 37.770452;
$longitude = -122.424923;
// Build requests for current time each month in last 75 years
$requests = array();
for ($i = 0; $i < 75*12; $i++) {
$requests[] = array(
'latitude' => $latitude,
'longitude' => $longitude,
'time' => strtotime("-$i months"),
);
}
// Make requests to the API
$responses = $forecast->getData($requests);
foreach ($responses as $response) {
if ($currently = $response->getCurrently()) {
$time = date("Y-m-d H:i:s", $currently->getTime());
$temp = $currently->getTemperature()
? number_format($currently->getTemperature(), 2) . '℉'
: "unknown";
echo "$time: $temp<br />\n";
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.