PHP code example of mahmut / meteoroloji-hava-durumu
1. Go to this page and download the library: Download mahmut/meteoroloji-hava-durumu 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/ */
mahmut / meteoroloji-hava-durumu example snippets
// hava durumunu getir
try {
$station = new \Meteoroloji\Entity\Station();
// şehir adı
$station->city = 'ankara';
// ilçe adı - boş bırakılabilir
$station->town = 'cankaya';
// konuma göre havadurumu getirilecekse
// enlem
$station->latitude = 39.903;
// boylam
$station->longitude = 32.809;
// konuma göre havadurumu bulunması için : \Meteoroloji\Entity\StationType::Location
// il/ilçeye göre havadurumu bulunması için : \Meteoroloji\Entity\StationType::City
$weather = new \Meteoroloji\Weather($station, \Meteoroloji\Entity\StationType::City);
$result = $weather
->setLanguage('tr') // ingilizce için 'en' kullanabilirsiniz.
->setCachePath(__DIR__ . '/cache/')
->cache(true)
->fetch();
print_r($result);
} catch (\Meteoroloji\Exception\CurrentNotFoundException $e) {
die($e->getMessage());
} catch (\Meteoroloji\Exception\ForecastNotFoundException $e) {
die($e->getMessage());
} catch (\Meteoroloji\Exception\StationNotFoundException $e) {
die($e->getMessage());
} catch (\Meteoroloji\Exception\Exception $e) {
die($e->getMessage());
}