Technologies Used
(Link: http://wx.uconn.edu/)
- PHP, JS, HTML, CSS + MySQL Database
- Built using Drupal v7
- 3rd Party Drupal Modules
At the Heart of the Portal
Weather Sources
We source weather information from 3 different sources:
- Weather.gov
- Weather Underground
- Accu Weather
Source #2 is no longer operational (maybe due to changes on Weather Underground's end?) and #3 was not implemented; therefore, the following is w/respect to just the first source.
Unified Weather Outlook
The home page of the Weather portal boasts weather of UConn Storrs, UConn Health and all UConn regional campuses: Storrs, Avery Point, Farmington, Hartford, Law School, Stamford, & Waterbury.
In the middle of the home/landing page, we are displaying a Satellite / Radar — however, the source Stormia.io seems to have shutdown its operations.
At the bottom of the home/landing page, we are displaying detailed forecast—for each of the 7 locations:
Method
The way we are accomplishing this, is using PHP Client URL Library (cURL) to fetch 7 different webpages from Weather.gov. I wrote a simple function that takes in a URL and then returns the fetched data—as shown below:
function fetch_weather($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0'); curl_setopt($ch, CURLOPT_REFERER, 'https://forecast.weather.gov'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); return $data; }
There are 7 distinct URLs (each URL has been pre-set to a specific campus), as shown in the table below:
The data returned by the method is then parsed and crafted; this is what yields the top and the bottom part of the page: weather at a glance, and the detailed weather sections respectively.
The middle part—the satellite/radar, is a simple iFrame embed.
The Sidebar
Event Ca