Display weather forecast using Forecast.io Weather API in ProcessWire. To be able to use the Forecast.io API you will have to signup at https://darksky.net/dev/ for an API Key.
Unzip/copy module directory to /site/modules/ directory.
Click "Refresh" on ProcessWire Admin Modules page and Forecast will appear in the Module list. Click "Install" button to install the module.
Once you have saved the Forecast.io API Key in the Module settings and have configured available module options you can call the module in your template as following.
<?php
$forecast = $modules->get('MarkupForecast');
$currently = $forecast->currently();
?>
This will return a multidimensional array of the current weather forecast.
Retrieving complete weather forecast which will return complete response from forecast.io:
$forecast->complete();
Retrieving minutely weather forecast:
$forecast->minutely();
Retrieving hourly weather forecast:
$forecast->hourly();
Retrieving daily weather forecast:
$forecast->daily();
Retrieving alerts:
$forecast->alerts();
If you need to make another call, in example retrieving forecast data for another city and overriding default module settings you can either use one of above mentioned methods using address or comma separated latitude and longitude string as function parameter $forecast->currently('My address');
or fetching complete forecast.
<?php
$forecast = $modules->get('MarkupForecast');
/**
* @param string $location A full address or comma separated latitude and longitude values
* @param int $time Optional UNIX time period for requested forecast
* @param array $options Optional options for forecast request url in exmaple units (possible values are,
* auto, ca, uk2, us, si) or lang, see https://darksky.net/dev/docs/forecast Documentation
* @param string $key Optional with this parameter results will be returned by a given array key
* @param bool $type Optional when true, results will be returned in JSON string
* @return array|string
*/
$fetch = $forecast->fetch('Some address');
?>
A Forecast.io API Key
The address of a location (in exmaple: Address, ZIP code, Country). To retrieve latitude and longitude of the location a Google Maps Geocode API will be used.
The latitude of a location (in decimal degrees). Positive is north, negative is south.
The longitude of a location (in decimal degrees). Positive is east, negative is west.
Returns summary properties in the desired language.
Returns weather conditions in the requested units.
A value in seconds for how long a cache of weather request should be preserved.