1. Go to this page and download the library: Download ndolestudio/darksky-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/ */
ndolestudio / darksky-php example snippets
class Request implements \DarkSky\Contracts\LocationDateTimeInput
{
public function getLatitude(): float
{
return 33.22;
}
public function getLongitude(): float
{
return 24.44;
}
public function getDateTime(): DateTime
{
return new DateTime('now');
}
}
// Require composer dependencies.
onfiguration
$apiConfiguration = new \DarkSky\Configurations\DarkSkyApiConfiguration(
['daily','currently'], // Excluded blocks
'https://api.darksky.net/forecast/b95b5555fb5f8e94cf499f4036618e55/', // Api Endpoint
'si' // Units
);
// Use the configuration to create a DarkSkyApiClient
$darkSkyApiClient = new \DarkSky\Clients\DarkSkyApiClient($apiConfiguration, new \GuzzleHttp\Client());
// Create an instance of the LocationDateTimeInput
$request = new Request();
// This fetches the json response
$jsonResponse = $darkSkyApiClient->fetchWeatherData($request);
composer install ndolestudio/darksky-php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.