2017 © Pedro Peláez
 

library open-weather-map

OpenWeatherMap Class

image

fu-hsi/open-weather-map

OpenWeatherMap Class

  • Friday, January 16, 2015
  • by fu-hsi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

OpenWeatherMap

Simple class for retrieve current weather., (*1)

Usage

 __DIR__,
    'lifeTime' => FileCache::HOUR * 3,
    'format' => FileCache::FORMAT_JSON
));

$cityNameKey = 'Warsaw';

$weatherData = $cache->get($cityNameKey, false, function () use ($cityNameKey)
{
    // all below options are default
    $options = array(
        'APPID' => '', // Your API key
        'units' => OpenWeatherMap::UNITS_METRIC,
        'lang' => OpenWeatherMap::LANG_POLISH
    );
    
    $weather = new OpenWeatherMap($options);
    return $weather->getCurrentWeatherByCityName($cityNameKey);
});

var_dump($weatherData);

?>

Retrieve weather by City name:, (*2)

$weatherData = $weather->getCurrentWeatherByCityName('Warsaw');

Retrieve weather by City name and Country code:, (*3)

$weatherData = $weather->getCurrentWeatherByCityName('Warsaw,pl');

Retrieve weather by City id (recommended):, (*4)

$weatherData = $weather->getCurrentWeatherByCityName(756135); 

Retrieve image:, (*5)

echo '<img src="' . OpenWeatherMap::getIconUrl($weatherData->weather[0]->icon) . '" alt="' . $weatherData->weather[0]->description . '">';

Install via Composer

{
    "require": {
        "fu-hsi/open-weather-map": "dev-master"
    },
    "minimum-stability": "dev"
}

The Versions

16/01 2015

dev-master

9999999-dev

OpenWeatherMap Class

  Sources   Download

MIT

The Requires

 

by Mariusz Kacki

weather