You are here

function wunderground_weather_get_current_data in Wunderground weather 7

Get current weather from Wunderground.

File

./wunderground_weather.module, line 638
Wunderground weather module to display weather forecasts and current weather conditions in blocks.

Code

function wunderground_weather_get_current_data($block_number = '') {
  $location = variable_get('wunderground_weather_location_current_' . $block_number, FALSE);
  if ($location) {
    preg_match('#\\[(.*?)\\]#', $location, $match);
    $path = $match[1];
    $options = array(
      'key' => variable_get('wunderground_weather_api_key', ''),
      'data_feature' => 'conditions',
      'language' => 'lang:' . strtoupper(variable_get('wunderground_weather_language', 'EN')),
      'path' => $path,
    );

    // Get data from wunderground.
    $data = wunderground_weather_http_request($options, $path);
  }
  else {
    $data['current_observation'] = FALSE;
  }
  return $data;
}