Update time-temp.php
This commit is contained in:
parent
bee6f195c3
commit
dca0bf78b5
|
@ -5,6 +5,15 @@ require('time-temp.inc.php');
|
|||
$cache_path = "/tmp/timetemp-".md5($url.$wunderkey.$feature.$path).".tmp";
|
||||
$from_cache = 0;
|
||||
|
||||
// by default do voice
|
||||
$voice = true;
|
||||
$sms = false;
|
||||
|
||||
if (array_key_exists('type', $_GET)) {
|
||||
if ($_GET['type'] == "voice") { $voice = true; $sms = false; }
|
||||
if ($_GET['type'] == "sms") { $voice = false; $sms = true; }
|
||||
}
|
||||
|
||||
// update weather every half hour
|
||||
if (file_exists($cache_path) && (time() - filemtime($cache_path) < 1800) ) {
|
||||
$response = file_get_contents($cache_path);
|
||||
|
@ -39,17 +48,24 @@ if ($obs->pressure_trend == "+") {
|
|||
|
||||
header('Content-Type: application/xml');
|
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>
|
||||
$out = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- from_cache: '.$from_cache.' filemtime: '.filemtime($cache_path).' -->
|
||||
<Response>
|
||||
<Message>The current time is '.$date->format('g:i:s A').', on '.$date->format('F j, Y').'. It is week number '.((int)$date->format('W')).' and day number '.((int)$date->format('z')).' of the year. It '.$dst_text.' currently Daylight Saving Time in '.$date->format('T').'. The temperature in '.$obs->observation_location->city.' was '.$obs->temp_f.'F today at '.$obs_date->format('g:i A').' (zyphon.com via wunderground.com)</Message>
|
||||
<Say voice="man">Hello. '.$date->format('g:i:s A').' is the current time, on '.$date->format('F j, Y').'. It is week number '.((int)$date->format('W')).' and day number '.((int)$date->format('z')).' of the year. It '.$dst_text.' currently Daylight Saving Time in '.$obs->display_location->city.'.</Say>
|
||||
<Response>';
|
||||
|
||||
if ($voice) {
|
||||
$out .= '<Say voice="man">Hello. '.$date->format('g:i:s A').' is the current time, on '.$date->format('F j, Y').'. It is week number '.((int)$date->format('W')).' and day number '.((int)$date->format('z')).' of the year. It '.$dst_text.' currently Daylight Saving Time in '.$obs->display_location->city.'.</Say>
|
||||
<Say voice="woman">Thank you for calling '.$obs->display_location->city.' Time and Temperature: a free hobby service, courtesy of zye fawn dot com, and Weather Underground dot com.</Say>
|
||||
<Say voice="man">The temperature in '.$obs->observation_location->city.' was '.$obs->temp_f.' degrees Fahrenheit today at '.$obs_date->format('g:i A').'. The weather was '.$obs->weather.' with winds '.$obs->wind_string.'. The dew point was '.$obs->dewpoint_f.' degrees, pressure '.$obs->pressure_mb.' millibars '.$pres_text.', visibility '.$obs->visibility_mi.' miles. The temperature felt like '.$obs->feelslike_f.' degrees.</Say>
|
||||
<Gather input="dtmf" timeout="5" numDigits="1">
|
||||
<Say voice="woman">Please press any key to hear this message again.</Say>
|
||||
</Gather>
|
||||
<Say voice="woman">Thanks again for calling. Goodbye.</Say>
|
||||
</Response>';
|
||||
<Say voice="woman">Thanks again for calling. Goodbye.</Say>';
|
||||
}
|
||||
|
||||
if ($sms) {
|
||||
$out .= '<Message>The current time is '.$date->format('g:i:s A').', on '.$date->format('F j, Y').'. It is week number '.((int)$date->format('W')).' and day number '.((int)$date->format('z')).' of the year. It '.$dst_text.' currently Daylight Saving Time in '.$date->format('T').'. The temperature in '.$obs->observation_location->city.' was '.$obs->temp_f.'F today at '.$obs_date->format('g:i A').' (zyphon.com via wunderground.com)</Message>';
|
||||
}
|
||||
|
||||
$out .= '</Response>';
|
||||
|
||||
echo $out;
|
||||
|
|
Loading…
Reference in New Issue
Block a user