Method | Description | |
---|---|---|
__construct ( string $apiKey = '', null | Cmfcmf\OpenWeatherMap\Fetcher\FetcherInterface $fetcher = null, boolean | string $cache = false, integer $seconds = 600 ) | Constructs the OpenWeatherMap object. | |
getApiKey ( ) : string | Returns the API Key. | |
getDailyWeatherForecast ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', integer $days = 1 ) : |
Returns the DAILY forecast for the place you specified. DANGER: Might return fewer results than requested due to a bug in the OpenWeatherMap API! | |
getRawDailyForecastData ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', string $mode = 'xml', integer $cnt = 16 ) : string | Directly returns the xml/json/html string returned by OpenWeatherMap for the daily forecast. | |
getRawData ( $query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml' ) | ||
getRawHourlyForecastData ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', string $mode = 'xml' ) : string | Directly returns the xml/json/html string returned by OpenWeatherMap for the hourly forecast. | |
getRawWeatherData ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', string $mode = 'xml' ) : string | Directly returns the xml/json/html string returned by OpenWeatherMap for the current weather. | |
getRawWeatherGroupData ( array $ids, string $units = 'imperial', string $lang = 'en', string $appid = '' ) : string | Directly returns the JSON string returned by OpenWeatherMap for the group of current weather. | |
getRawWeatherHistory ( array | integer | string $query, DateTime $start, DateTime | integer $endOrCount = 1, string $type = 'hour', string $units = 'imperial', string $lang = 'en', string $appid = '' ) : string | Directly returns the xml/json/html string returned by OpenWeatherMap for the weather history. | |
getWeather ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '' ) : |
Returns the current weather at the place you specified. | |
getWeatherForecast ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', integer $days = 1 ) : |
Returns the forecast for the place you specified. DANGER: Might return fewer results than requested due to a bug in the OpenWeatherMap API! | |
getWeatherGroup ( array $ids, string $units = 'imperial', string $lang = 'en', string $appid = '' ) : Array | Returns the current weather for a group of city ids. | |
getWeatherHistory ( array | integer | string $query, DateTime $start, integer $endOrCount = 1, string $type = 'hour', string $units = 'imperial', string $lang = 'en', string $appid = '' ) : |
Returns the weather history for the place you specified. | |
setApiKey ( string $apiKey ) | Sets the API Key. | |
wasCached ( ) : boolean | Returns whether or not the last result was fetched from the cache. |
Method | Description | |
---|---|---|
buildQueryUrlParameter ( mixed $query ) : string | Builds the query string for the url. | |
buildUrl ( $query, $units, $lang, $appid, $mode, string $url ) : boolean | string | Build the url to fetch weather data from. | |
cacheOrFetchResult ( string $url ) : string | Fetches the result or delivers a cached version of the result. | |
parseJson ( string $answer ) : stdClass | ||
parseXML ( string $answer ) : SimpleXMLElement |
public __construct ( string $apiKey = '', null | Cmfcmf\OpenWeatherMap\Fetcher\FetcherInterface $fetcher = null, boolean | string $cache = false, integer $seconds = 600 ) | ||
$apiKey | string | The OpenWeatherMap API key. Required and only optional for BC. |
$fetcher | null | Cmfcmf\OpenWeatherMap\Fetcher\FetcherInterface | The interface to fetch the data from OpenWeatherMap. Defaults to CurlFetcher() if cURL is available. Otherwise defaults to FileGetContentsFetcher() using 'file_get_contents()'. |
$cache | boolean | string | If set to false, caching is disabled. Otherwise this must be a class extending AbstractCache. Defaults to false. |
$seconds | integer | How long weather data shall be cached. Default 10 minutes. |
public getDailyWeatherForecast ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', integer $days = 1 ) : |
||
$query | array | integer | string | The place to get weather information for. For possible values see ::getWeather. |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
$days | integer | For how much days you want to get a forecast. Default 1, maximum: 16. |
return |
public getRawDailyForecastData ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', string $mode = 'xml', integer $cnt = 16 ) : string | ||
$query | array | integer | string | The place to get weather information for. For possible values see ::getWeather. |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
$mode | string | The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default) |
$cnt | integer | How many days of forecast shall be returned? Maximum (and default): 16 |
return | string | Returns false on failure and the fetched data in the format you specified on success. Warning: If an error occurs, OpenWeatherMap ALWAYS returns json data. |
public getRawData ( $query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml' ) |
public getRawHourlyForecastData ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', string $mode = 'xml' ) : string | ||
$query | array | integer | string | The place to get weather information for. For possible values see ::getWeather. |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
$mode | string | The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default). |
return | string | Returns false on failure and the fetched data in the format you specified on success. Warning: If an error occurs, OpenWeatherMap ALWAYS returns json data. |
public getRawWeatherData ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', string $mode = 'xml' ) : string | ||
$query | array | integer | string | The place to get weather information for. For possible values see ::getWeather. |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
$mode | string | The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default). |
return | string | Returns false on failure and the fetched data in the format you specified on success. Warning: If an error occurs, OpenWeatherMap ALWAYS returns json data. |
public getRawWeatherGroupData ( array $ids, string $units = 'imperial', string $lang = 'en', string $appid = '' ) : string | ||
$ids | array | The city ids to get weather information for |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
return | string | Returns false on failure and the fetched data in the format you specified on success. |
public getRawWeatherHistory ( array | integer | string $query, DateTime $start, DateTime | integer $endOrCount = 1, string $type = 'hour', string $units = 'imperial', string $lang = 'en', string $appid = '' ) : string | ||
$query | array | integer | string | The place to get weather information for. For possible values see ::getWeather. |
$start | DateTime | The \DateTime object of the date to get the first weather information from. |
$endOrCount | DateTime | integer | Can be either a \DateTime object representing the end of the period to receive weather history data for or an integer counting the number of reports requested. |
$type | string | The period of the weather history requested. Can be either be either "tick", "hour" or "day". |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
return | string | Returns false on failure and the fetched data in the format you specified on success. Warning If an error occurred, OpenWeatherMap ALWAYS returns data in json format. |
public getWeather ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '' ) : |
||
$query | array | integer | string | The place to get weather information for. For possible values see below. |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
return | The weather object. There are three ways to specify the place to get weather information for: - Use the city name: $query must be a string containing the city name. - Use the city id: $query must be an integer containing the city id. - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. |
public getWeatherForecast ( array | integer | string $query, string $units = 'imperial', string $lang = 'en', string $appid = '', integer $days = 1 ) : |
||
$query | array | integer | string | The place to get weather information for. For possible values see ::getWeather. |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
$days | integer | For how much days you want to get a forecast. Default 1, maximum: 16. |
return |
public getWeatherGroup ( array $ids, string $units = 'imperial', string $lang = 'en', string $appid = '' ) : Array | ||
$ids | array | The city ids to get weather information for |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
return | Array | Array of CurrentWeather objects. |
public getWeatherHistory ( array | integer | string $query, DateTime $start, integer $endOrCount = 1, string $type = 'hour', string $units = 'imperial', string $lang = 'en', string $appid = '' ) : |
||
$query | array | integer | string | The place to get weather information for. For possible values see ::getWeather. |
$start | DateTime | |
$endOrCount | integer | |
$type | string | Can either be 'tick', 'hour' or 'day'. |
$units | string | Can be either 'metric' or 'imperial' (default). This affects almost all units returned. |
$lang | string | The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi. |
$appid | string | Your app id, default ''. See http://openweathermap.org/appid for more details. |
return |