Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: code formatting for better readability

...

Code Block
languagephp
themeRDark
titleFetch Weather Method
linenumberstrue
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:

...