<?php require_once 'plivo.php'; $record_url = $_REQUEST['RecordUrl']; $response = new Response(); $getdigits = $response->addGetDigits(array('action' => 'http://' . $_SERVER["SERVER_NAME"] . '/plivo-voicemail/follow-action.php?RecordUrl=' . $record_url, 'method' => 'GET')); $getdigits->addSpeak('Press 1 to play your recording'); $getdigits->addSpeak('Press 2 to start over'); $getdigits->addSpeak('Press 3 to save and exit'); header('content-type: text/xml'); echo $response->toXML();
require_once "plivo.php"; # This file will be played when a caller presses 2. $PLIVO_SONG = "https://s3.amazonaws.com/plivocloud/music.mp3"; # This is the message that Plivo reads when the caller dials in $IVR_MESSAGE1 = "Welcome to the Plivo IVR Demo App. Press 1 to listen to a pre recorded text in different languages. Press 2 to listen to a song."; $IVR_MESSAGE2 = "Press 1 for English. Press 2 for French. Press 3 for Russian"; # This is the message that Plivo reads when the caller does nothing at all $NO_INPUT_MESSAGE = "Sorry, I didn't catch that. Please hangup and try again later."; # This is the message that Plivo reads when the caller inputs a wrong number. $WRONG_INPUT_MESSAGE = "Sorry, wrong input."; $r = new Response(); switch ($_SERVER['REQUEST_METHOD']) { case "GET": $getdigits_action_url = "https://example.com/phone_ivr.php"; $params = array('action' => $getdigits_action_url, 'method' => 'POST', 'timeout' => '7', 'numDigits' => '1', 'retries' => '1'); $getDigits = $r->addGetDigits($params); $getDigits->addSpeak($IVR_MESSAGE1); $r->addSpeak($NO_INPUT_MESSAGE); Header('Content-type: text/xml'); echo $r->toXML(); break; case "POST": $digit = $_REQUEST['Digits']; if ($digit == '1') { $getdigits_action_url = "https://example.com/phone_tree.php"; $params = array('action' => $getdigits_action_url, 'method' => 'GET', 'timeout' => '7', 'numDigits' => '1', 'retries' => '1'); $getDigits = $r->addGetDigits($params); $getDigits->addSpeak($IVR_MESSAGE2); $r->addSpeak($NO_INPUT_MESSAGE); } else { if ($digit == '2') {
public function testGetDigitsNestedElementsConvienceMethods() { $r = new Response(); $g = $r->addGetDigits(array("action" => "example.com", "method" => "GET")); $g->addSpeak("Hello World"); $g->addPlay("helloworld.mp3"); $g->addWait(); $expected = ' <Response> <GetDigits action="example.com" method="GET"> <Speak>Hello World</Speak> <Play>helloworld.mp3</Play> <Wait></Wait> </GetDigits> </Response>'; $this->assertXmlStringEqualsXmlString($expected, $r->asUrl(False)); }
<?php require_once 'plivo.php'; $body = 'Hi, Calling from Plivo. Please enter 1 for music and 2 for Speak.'; // $url = 'http://examples.com/playTrumpet.mp3'; $attributes = array('loop' => 2); $getdigitattributes = array('action' => 'http://' . $_SERVER["SERVER_NAME"] . '/gather'); // This is the url where 'Digits' parameter would be sent after user's digit press event $r = new Response(); $g = $r->addGetDigits($getdigitattributes); $g->addSpeak($body, $attributes); $r->addSpeak("Input not recieved", array('language' => 'en-US', 'voice' => 'WOMAN')); echo $r->toXML();
<?php require_once 'plivo-voicemail/plivo.php'; $r = new Response(); /*Input digits can be processed on the action url*/ $g = $r->addGetDigits(array('action' => 'http://server.com/receive_input.php', 'method' => 'GET')); $g->addSpeak('Press 1 for your message'); $r->addSpeak('Input not received'); header('Content-Type: text/xml'); echo $r->toXML();
<?php // Include the PHP Plivo Rest library require "./plivohelper.php"; $base_http = "http://" . dirname($_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]); /* Render RESTXML */ $r = new Response(); if (isset($_POST['Digits'])) { $digits = $_POST['Digits']; if ($digits != "") { $r->addSpeak("Get Digits. Digits pressed " . $digits); } else { $r->addSpeak("Get Digits. No digits pressed"); } } else { $d = $r->addGetDigits(array("action" => $base_http . "/answered.php", "timeout" => 10, "retries" => 2, "finishOnKey" => "#", "numDigits" => 2, "playBeep" => "true", "validDigits" => "01234")); $d->addSpeak("Get Digits. Press 0, 1, 2, 3 or 4"); } $r->Respond();