Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- include('functions.php');
- global $set;
- $lat = 33.777444;
- $lon = -84.405116;
- $zip = 30332;
- $timezone = get_time_zone("US","GA");
- date_default_timezone_set($timezone);
- $zenith = 96;
- $tzoffset = date("Z")/60 / 60;
- $set = day_or_night($lat,$lon,$tzoffset,$zenith);
- $data = get_cached_file('http://api.wunderground.com/api/84ca38f278f3d8b2/conditions/q/GA/Atlanta.json');
- $data2 = get_cached_file('http://api.wunderground.com/api/84ca38f278f3d8b2/forecast/q/GA/Atlanta.json');
- $data = json_decode($data);
- $data2 = json_decode($data2);
- //print_r($data2->forecast->simpleforecast->forecastday);
- // Get icon # from data
- $current = $data->current_observation;
- $current_json = array(
- 'update_time'=>date('g:i a',$current->observation_epoch),
- 'temperature'=>((int)$current->temp_f).'°',
- 'wind'=>((int)$current->wind_mph).'mph',
- 'weather'=>$current->weather,
- 'icon'=>get_icon($current->icon),
- 'precip'=>$data2->forecast->simpleforecast->forecastday[0]->pop.'%'
- );
- $forecast_array = array();
- foreach($data2->forecast->simpleforecast->forecastday as $forecast)
- {
- $data = array(
- 'day'=>$forecast->date->weekday_short,
- 'high'=>$forecast->high->fahrenheit.'°',
- 'low'=>$forecast->low->fahrenheit.'°',
- 'icon'=>get_icon($forecast->icon,true),
- 'precip'=>$forecast->pop
- );
- array_push($forecast_array,$data);
- }
- $json =
- json_encode(
- array(
- 'place'=>$current->display_location->full,
- 'current_conditions'=>$current_json,
- 'forecast'=>$forecast_array
- )
- );
- echo 'weather('.$json.');';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement