<?php require_once 'lib/plivo.php'; $r = new Response(); $body = 'Hi, Calling from Plivo'; $url = 'http://examples.com/playTrumpet.mp3'; $attributes = array('loop' => 2); $r->addSpeak($body, $attributes); $r->addPlay($url, $attributes); $wait_attribute = array('length' => 3); $r->addWait($wait_attribute); header('Content-type: text/xml'); echo $r->toXML();
<?php require_once "./plivo.php"; $r = new Response(); $getdigits_action_url = "https://example.com/recording_action.php"; $params = array('action' => $getdigits_action_url, 'method' => 'GET', 'timeout' => '7', 'numDigits' => '1', 'retries' => '1', 'redirect' => 'false'); $getDigits = $r->addGetDigits($params); $getDigits->addSpeak("Press 1 to record this call"); $waitparam = array('length' => '10'); $r->addWait($waitparam); Header('Content-type: text/xml'); echo $r->toXML(); ?> <!--recording_action.php--> <?php require_once "./plivo.php"; $digit = $_REQUEST['Digits']; $uuid = $_REQUEST['CallUUID']; print "Digit : {$digit}"; print "Call UUID : {$uuid}"; $auth_id = "Your AUTH_ID"; $auth_token = "Your AUTH_TOKEN"; $p = new RestAPI($auth_id, $auth_token); if ($digit == "1") { $params = array('call_uuid' => $uuid); $response = $p->record($params); print "URL : {$response['response']['url']}"; print "Recording ID : {$response['response']['recording_id']}"; print "API ID : {$response['response']['api_id']}";
<?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(); $r->addWait(array('length' => 60)); $r->Respond();
public function testWaitConvience() { $r = new Response(); $r->addWait(); $expected = '<Response><Wait></Wait></Response>'; $this->assertXmlStringEqualsXmlString($expected, $r->asUrl(False)); }
</Response> */ // The same XML can be created above using the convencience methods $r = new Response(); $r->addSpeak("Hello World", array("loop" => "10")); $g = $r->addDial(array("timeLimit" => "45")); $g->addNumber("4155551212"); $r->addPlay("http://www.mp3.com"); $r->addHangup(array("schedule" => "45")); $r->Respond(); // ======================================================================== // GetDigits, Redirect $r = new Response(); $g = $r->addgetDigits(array("numDigits" => "1", "timeout" => "25", "playBeep" => "true")); $g->addPlay("/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-hello.wav", array("loop" => "10")); $r->addWait(array("length" => "5")); $r->addPlay("/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-hello.wav", array("loop" => "10")); $r->addRecord(array("bothLegs" => "true")); $r->addredirect(); $r->Respond(); /* outputs: <Response> <GetDigits numdigits="1"> <Play loop="2">/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-hello.wav</Play> </GetDigits> <Wait length="5"/> <Play loop="2">/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-hello.wav</Play> <Record/> <Hangup/> </Response> */
$machine = $_REQUEST['Machine']; $call_uuid = $_REQUEST['CallUUID']; $event = $_REQUEST['Event']; $call_status = $_REQUEST['CallStatus']; error_log("From = {$from_number} , To = {$to_number} , Machine = {$machine} , Call UUID = {$call_uuid} , Event = {$event} , Call Status = {$call_status}"); echo "From = {$from_number} , To = {$to_number} , Machine = {$machine} , Call UUID = {$call_uuid} , Event = {$event} , Call Status = {$call_status}"; ?> <!-- detect.php--> <?php require_once "./plivo.php"; $r = new Response(); // Add Wait tag $params = array('length' => '1000', 'silence' => 'true', 'minSilence' => '3000'); $r->addWait($params); // Add Speak tag $body = "Hello voicemeail"; $r->addSpeak($body); Header('Content-type: text/xml'); echo $r->toXML(); /* Sample Output <Response> <Wait length="10" silence="true" minSilence="500"/> <Speak>Hello Voicemail!</Speak> </Response> From = 1111111111 , To = 2222222222 , Machine = true , Call UUID = fee30404-aee9-11e4-a5d9-850813b6efc3 , Event = MachineDetection , Call Status = in-progress */