PHP code example of rakibdevs / openweather-laravel-api
1. Go to this page and download the library: Download rakibdevs/openweather-laravel-api 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/ */
rakibdevs / openweather-laravel-api example snippets
return [
'api_key' => env('OPENWEATHER_API_KEY', ''),
'onecall_api_version' => '2.5',
'historical_api_version' => '2.5',
'forecast_api_version' => '2.5',
'polution_api_version' => '2.5',
'geo_api_version' => '1.0',
'lang' => env('OPENWEATHER_API_LANG', 'en'),
'date_format' => 'm/d/Y',
'time_format' => 'h:i A',
'day_format' => 'l',
'temp_format' => 'c' // c for celcius, f for farenheit, k for kelvin
];
use RakibDevs\Weather\Weather;
$wt = new Weather();
$info = $wt->getCurrentByCity('dhaka'); // Get current weather by city name
// By city name
$info = $wt->getCurrentByCity('dhaka');
// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
$info = $wt->getCurrentByCity(1185241);
// By Zip Code - string with country code
$info = $wt->getCurrentByZip('94040,us'); // If no country code specified, us will be default
// By coordinates : latitude and longitude
$info = $wt->getCurrentByCord(23.7104, 90.4074);
// By coordinates : latitude and longitude
$info = $wt->getOneCallByCord(23.7104, 90.4074);
// By city name
$info = $wt->get3HourlyByCity('dhaka');
// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
$info = $wt->get3HourlyByCity(1185241);
// By Zip Code - string with country code
$info = $wt->get3HourlyByZip('94040,us'); // If no country code specified, us will be default
// By coordinates : latitude and longitude
$info = $wt->get3HourlyByCord(23.7104, 90.4074);
// By coordinates : latitude, longitude and date
$info = $wt->getHistoryByCord(23.7104, 90.4074, '2020-01-09');
// By coordinates : latitude, longitude and date
$info = $wt->getAirPollutionByCord(23.7104, 90.4074);
// By city name
$info = $wt->getGeoByCity('dhaka');
// By coordinates : latitude, longitude and date
$info = $wt->getGeoByCity(23.7104, 90.4074);
$ php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.