A basic PHP script that grabs and outputs Weather Data in JSON for use on other UCF sites.
Uses a simple caching mechanism that saves previously grabbed results and
refers to that saved file if another request is made within the set cache duration.
Conditions retrieved are relative to the Orlando area, but can be updated for other projects
by modifying the WEATHER_URL_CURRENT
and WEATHER_URL_FORECAST
constants.
The script is currently written to accept and parse NOAA XML data. Condition codes for images are strings by default but are converted to the Weather.com/Yahoo condition code standard (since most of our sites are already using it anyway.) These condition codes are also used to generate a condition phrase, due to the default NOAA condition phrases being very verbose.
Links to various icon sets are provided within the feed; img/weather-small/
contains icons used
on ucf.edu; img/weather-medium/
contains icons used in the GMUCF emails; img/weather-large/
contains icons used on UCF Today.
The Orlando area's current conditions feed is returned by default when index.php is requested.
Use the GET parameter data
to return different sets of data:
Either 'yes' or 'no'; if the requested data was successfully fetched from the specified external source, this value is set to 'yes'. If some particular content is missing from the external source for any day, this value is set to 'no'.
The URL of the Weather Data provider.
The date for the given set of weather conditions. (Format YYYY-MM-DD)
A weather condition phrase. These phrases are based loosely on the Yahoo Weather API code descriptions: (http://developer.yahoo.com/weather/#codetable)
A status condition code, based on the status code provided by NOAA. This code is translated into a Weather.com/Yahoo numerical condition code.
Links to relevant weather icons. img/weather-small/
contains icons used on ucf.edu;
img/weather-medium/
contains icons used in the GMUCF emails; img/weather-large/
contains icons
used on UCF Today.
The timestamp when this set of Weather Data was last cached.
The timestamp when the feed provider (NOAA) last updated their feed content.
Current temperature reading. (Includes degree symbol)
Current temperature reading. (Does not include degree symbol)
Maximum predicted temperature for that day. (Includes degree symbol)
Maximum predicted temperature for that day. (Does not include degree symbol)
Minimum predicted temperature for that day. (Includes degree symbol.) Note that a 'day7' tempMin is not provided by NOAA.
Minimum predicted temperature for that day. (Does not include degree symbol.)