Last active
December 23, 2015 16:29
-
-
Save mheadd/6662059 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define("AIRPORT_API_ENDPOINT", "http://54.235.132.110/number/"); | |
| define("TTS_VOICE", "Veronica"); | |
| function getFlightInfo($flightNum) { | |
| return json_decode(file_get_contents(AIRPORT_API_ENDPOINT . $flightNum)); | |
| } | |
| answer(); | |
| // Say hello to caller. | |
| say("Welcome to the Philly International Airport Flight information line", array("voice" => TTS_VOICE)); | |
| // Ask for flight direction. | |
| $direction = ask("Are you calling about an arrival or departure?", array("bargein" => false, "choices" => "arrival, departure", "attempts" => "3", "voice" => TTS_VOICE)); | |
| // Ask for flight number. | |
| $flightNum = ask("Say or enter the numeric portion of your flight number.", array("bargein" => false, "choices" => "[3-4 DIGITS]", "attempts" => "3", "voice" => TTS_VOICE)); | |
| // Get flight data | |
| $flightJSON = getFlightInfo($flightNum); | |
| for($i=0; $i<count($flightJSON); $i++) { | |
| if($flightJSON[$i]->direction == strtolower($direction)) { | |
| say("Flight number, " . implode(" ", explode("", $flightNum)), array("voice" => TTS_VOICE)); | |
| $sayDirection = ($direction == "arrival") ? "Ariving from" : "Departing for"; | |
| say("$sayDirection, " . $flightJSON[$i]->airport, array("voice" => TTS_VOICE)); | |
| say("At gate, " . $flightJSON[$i]->gate, array("voice" => TTS_VOICE)); | |
| say("On, " . date("F j, Y, g:i a", $flightJSON[$i]->estimatedDateTime), array("voice" => TTS_VOICE)); | |
| } | |
| } | |
| say("Thanks for calling. Goodbye.", array("voice" => TTS_VOICE)); | |
| hangup(); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment