Ah, weatherstack.com appears to have been so kind as to include a few code examples, so you can have a look on how to integrate it. There’s a PHP one too, which looks like this:
$location = 'New York';
$queryString = http_build_query([
'access_key' => 'YOUR_ACCESS_KEY',
'query' => $location,
]);
$ch = curl_init(sprintf('%s?%s', 'https://api.weatherstack.com/current', $queryString));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
$api_result = json_decode($json, true);
echo "Current temperature in $location is {$api_result['current']['temperature']}℃", PHP_EOL;
…where YOUR_ACCESS_KEY is handed to you when you sign up.
This code could be inserted into any PHP page in your RapidWeaver project and the current temperature for New York would be shown in Celsius to your visitors.
The bit that contains $ch = curl_init is where the magic happens - this reads out the variables created just above it ($location and $querystring) and builds the URL that fetches the weatherdata from the location you specified with your subs’ credentials, and puts it into a new variable called $ch.
The weatherdata returned ends up in a variable called in $api_result, which is then put in a string that formats it into a nice English sentence in echo.
You could build yourself a new string, or include the {$api_result[‘current’][‘temperature’]} in pretty much any stack that allows text input, as long as your page is in PHP.
You can look up other data then temperature too, including one that returns a PNG icon:
current > observation_time Returns the UTC time for when the returned whether data was collected.
current > temperature Returns the temperature in the selected unit. (Default: Celsius)
current > weather_code Returns the universal weather condition code associated with the current weather condition. You can download all available weather codes using this link: Download Weather Codes (ZIP file)
current > weather_icons Returns one or more PNG weather icons associated with the current weather condition.
current > weather_descriptions Returns one or more weather description texts associated with the current weather condition.
current > wind_speed Returns the wind speed in the selected unit. (Default: kilometers/hour)
current > wind_degree Returns the wind degree.
current > wind_dir Returns the wind direction.
current > pressure Returns the air pressure in the selected unit. (Default: MB - millibar)
current > precip Returns the precipitation level in the selected unit. (Default: MM - millimeters)
current > humidity Returns the air humidity level in percentage.
current > cloudcover Returns the cloud cover level in percentage.
current > feelslike Returns the "Feels Like" temperature in the selected unit. (Default: Celsius)
current > uv_index Returns the UV index associated with the current weather condition.
current > visibility Returns the visibility level in the selected unit. (Default: kilometers)
Keep in mind that the free tier will only allow 250 polls per month, after which some kind of message probably appears instead of the temperature (in this example). Depending on how many visitors (including crawlers and whatnots) you expect, this may result in ugly errors quite quickly. The cheapest paid plan allows for 50,000 polls, which sounds about realistic.
Cheers,
Erwin