diff --git a/src/mod/applications/mod_httapi/examples/PHP/dialer.php b/src/mod/applications/mod_httapi/examples/PHP/dialer.php new file mode 100644 index 0000000000..aae11cc51e --- /dev/null +++ b/src/mod/applications/mod_httapi/examples/PHP/dialer.php @@ -0,0 +1,42 @@ +openMemory(); +$xml->setIndent(1); +$xml->startDocument(); + +if ( $_REQUEST['exiting'] ) { + header('Content-Type: text/plain'); + print "OK"; + exit(); +} + +header('Content-Type: text/xml'); +$xml->startElement('document'); +$xml->writeAttribute('type', 'xml/freeswitch-httapi'); + +$xml->startElement('work'); + +$xml->startElement('pause'); +$xml->writeAttribute('milliseconds', '1500'); +$xml->endElement(); // + +$xml->startElement('playback'); +$xml->writeAttribute('name', 'digits'); +$xml->writeAttribute('file', 'http://sidious.freeswitch.org/sounds/exten.wav'); +$xml->writeAttribute('error-file', 'http://sidious.freeswitch.org/sounds/invalid.wav'); +$xml->writeAttribute('input-timeout', '5000'); +$xml->writeAttribute('action', 'dial:default:XML'); + +$xml->startElement("bind"); +$xml->writeAttribute('strip',"#"); +$xml->text("~\\d+\#"); +$xml->endElement(); // +$xml->endElement(); // + +$xml->endElement(); // +$xml->endElement(); // + +print $xml->outputMemory(); + + + diff --git a/src/mod/applications/mod_httapi/examples/PHP/ext_pin.php b/src/mod/applications/mod_httapi/examples/PHP/ext_pin.php new file mode 100644 index 0000000000..1d778cf482 --- /dev/null +++ b/src/mod/applications/mod_httapi/examples/PHP/ext_pin.php @@ -0,0 +1,111 @@ +openMemory(); +$xml->setIndent(1); +$xml->startDocument(); + +if ( array_key_exists( 'exten', $_REQUEST ) ) { + $exten = $_REQUEST['exten']; +} elseif ( array_key_exists( 'exten', $_SESSION ) ) { + $exten = $_SESSION['exten']; +} else { + $exten = ''; +} + +if ( array_key_exists( 'pin', $_REQUEST ) ) { + $pin = $_REQUEST['pin']; +} elseif ( array_key_exists( 'pin', $_SESSION ) ) { + $pin = $_SESSION['pin']; +} else { + $pin = ''; +} + +if ( array_key_exists( 'exiting', $_REQUEST ) ) { + $exiting = $_REQUEST['exiting']; +} elseif ( array_key_exists( 'exiting', $_SESSION ) ) { + $exiting = $_SESSION['exiting']; +} else { + $exiting = ''; +} + +if ( $exiting ) { + header('Content-Type: text/plain'); + print "OK"; + exit(); +} + +header('Content-Type: text/xml'); +$xml->startElement('document'); +$xml->writeAttribute('type', 'xml/freeswitch-httapi'); + +if ( $exten && $pin ) { + $xml->startElement('work'); + $xml->writeElement("playback", "http://sidious.freeswitch.org/sounds/ext_num.wav"); + + $xml->startElement("say"); + $xml->writeAttribute('language', "en"); + $xml->writeAttribute('type', "name_spelled"); + $xml->writeAttribute('method', "pronounced"); + $xml->text($exten); + $xml->endElement(); // + + $xml->startElement('pause'); + $xml->writeAttribute('milliseconds', "1500"); + $xml->endElement(); // + + $xml->startElement("say"); + $xml->writeAttribute('language', "en"); + $xml->writeAttribute('type', "name_spelled"); + $xml->writeAttribute('method', "pronounced"); + $xml->text($pin); + $xml->endElement(); // + + $xml->writeElement('hangup'); + $xml->endElement(); // +} elseif ( $exten ) { + $_SESSION['exten'] = $exten; + + $xml->startElement('work'); + $xml->startElement('playback'); + $xml->writeAttribute('name', "pin"); + $xml->writeAttribute('file', "http://sidious.freeswitch.org/sounds/pin.wav"); + $xml->writeAttribute('error-file', "http://sidious.freeswitch.org/sounds/bad-pin.wav"); + $xml->writeAttribute('input-timeout', "5000"); + + $xml->startElement("bind"); + $xml->writeAttribute('strip', "#"); + $xml->text("~\\d+\#"); + $xml->endElement(); // + + $xml->endElement(); // + $xml->endElement(); // +} else { + $xml->startElement('work'); + + $xml->startElement('playback'); + $xml->writeAttribute('name', "exten"); + $xml->writeAttribute('file', "http://sidious.freeswitch.org/sounds/exten.wav"); + $xml->writeAttribute('loops', "3"); + $xml->writeAttribute('error-file', "http://sidious.freeswitch.org/sounds/invalid.wav"); + $xml->writeAttribute('input-timeout', "5000"); + + $xml->startElement("bind"); + $xml->writeAttribute('strip', "#"); + $xml->text("~\\d+\#"); + $xml->endElement(); // + + $xml->endElement(); // + $xml->endElement(); // +} + +$xml->endElement(); // + +print $xml->outputMemory(); + + + diff --git a/src/mod/applications/mod_httapi/examples/PHP/record_name.php b/src/mod/applications/mod_httapi/examples/PHP/record_name.php new file mode 100644 index 0000000000..235cec5f09 --- /dev/null +++ b/src/mod/applications/mod_httapi/examples/PHP/record_name.php @@ -0,0 +1,71 @@ +openMemory(); +$xml->setIndent(1); +$xml->startDocument(); + +if ( array_key_exists( 'exiting', $_REQUEST ) ) { + $exiting = $_REQUEST['exiting']; +} elseif ( array_key_exists( 'exiting', $_SESSION ) ) { + $exiting = $_SESSION['exiting']; +} else { + $exiting = ''; +} + +if ( $_FILES && array_key_exists( 'recorded_file', $_FILES ) ) { + move_uploaded_file($_FILES['recorded_file']['tmp_name'], '/tmp/' . $_FILES['recorded_file']['name']); + trigger_error( print_r( $_FILES, true ) ); + + header('Content-Type: text/plain'); + print "OK\n"; + exit(); +} + +if ( $exiting ) { + header('Content-Type: text/plain'); + print "OK"; + exit(); +} + +header('Content-Type: text/xml'); +$xml->startElement('document'); +$xml->writeAttribute('type', 'xml/freeswitch-httapi'); + +$xml->startElement('work'); + +$xml->startElement('pause'); +$xml->writeAttribute('milliseconds', "1500"); +$xml->endElement(); + +$xml->startElement('playback'); +$xml->writeAttribute('file', "http://sidious.freeswitch.org/eg/ivr-say_name.wav"); +$xml->endElement(); + +$xml->startElement('record'); +$xml->writeAttribute('name', "recorded_file"); +$xml->writeAttribute('file', $_REQUEST['session_id'] . ".wav"); +$xml->writeAttribute('error-file', "http://sidious.freeswitch.org/sounds/invalid.wav"); +$xml->writeAttribute('input-timeout', "5000"); +$xml->writeAttribute('beep-file', "tone_stream://%(1000,0,460)"); +$xml->endElement(); + +$xml->startElement("bind"); +$xml->writeAttribute('strip', "#"); +$xml->text("~\\d+\#"); +$xml->endElement(); + + + +$xml->endElement(); // + +$xml->endElement(); // + +print $xml->outputMemory(); + + + diff --git a/src/mod/applications/mod_httapi/examples/PHP/speech.php b/src/mod/applications/mod_httapi/examples/PHP/speech.php new file mode 100644 index 0000000000..bfba2c6fd7 --- /dev/null +++ b/src/mod/applications/mod_httapi/examples/PHP/speech.php @@ -0,0 +1,93 @@ +openMemory(); +$xml->setIndent(1); +$xml->startDocument(); + +if ( array_key_exists( 'exiting', $_REQUEST ) ) { + $exiting = $_REQUEST['exiting']; +} elseif ( array_key_exists( 'exiting', $_SESSION ) ) { + $exiting = $_SESSION['exiting']; +} else { + $exiting = ''; +} + +if ( array_key_exists( 'result', $_REQUEST ) ) { + $result = $_REQUEST['result']; +} elseif ( array_key_exists( 'result', $_SESSION ) ) { + $result = $_SESSION['result']; +} else { + $result = ''; +} + +if ( array_key_exists( 'input_type', $_REQUEST ) ) { + $input_type = $_REQUEST['input_type']; +} elseif ( array_key_exists( 'input_type', $_SESSION ) ) { + $input_type = $_SESSION['input_type']; +} else { + $input_type = ''; +} + +if ( $exiting ) { + header('Content-Type: text/plain'); + print "OK"; + exit(); +} + +header('Content-Type: text/xml'); +$xml->startElement('document'); +$xml->writeAttribute('type', 'xml/freeswitch-httapi'); + +if ($result) { + $xml->startElement('work'); + + if ($type == "dtmf") { + $xml->startElement("say"); + $xml->writeAttribute('language', "en"); + $xml->writeAttribute('type', "name_spelled"); + $xml->writeAttribute('method', "pronounced"); + $xml->text( $result ); + } + + $xml->startElement("log"); + $xml->writeAttribute('level', "crit"); + $xml->text($result); + $xml->endElement(); + + $xml->writeElement('hangup'); + $xml->endElement(); +} else { + $xml->startElement('work'); + + $xml->startElement('pause'); + $xml->writeAttribute('milliseconds', "1500"); + $xml->endElement(); + + $xml->startElement('playback'); + $xml->writeAttribute('name', "result"); + $xml->writeAttribute('asr-engine', "pocketsphinx"); + $xml->writeAttribute('asr-grammar', "pizza_yesno"); + $xml->writeAttribute('file', "http://sidious.freeswitch.org/sounds/ConfirmDelivery.wav"); + $xml->writeAttribute('error-file', "http://sidious.freeswitch.org/sounds/invalid.wav"); + + $xml->startElement("bind"); + $xml->writeAttribute('strip', "#"); + $xml->text("~\\d+\#"); + $xml->endElement(); + + $xml->endElement(); + + $xml->endElement(); +} + +$xml->endElement(); // + +print $xml->outputMemory(); + + +