public function testSayConvienceMethod() { $r = new Response(); $r->addSay("Hello Monkey", array("language" => "fr")); $expected = '<Response><Say language="fr">Hello Monkey</Say></Response>'; $this->assertXmlStringEqualsXmlString($expected, $r->asUrl(False)); }
public function callSay($text) { $twiml = new Response(); //generate url to the selected flow $twiml->addSay($text); $twiml->addPause(array('length' => 60 * 4)); $twiml->addHangup(); $this->startClientCall($twiml); }
function connect($number, $ext) { header('X-WP-Click2Call: ' . WP_CLICK2CALL_VERSION); $twilio = new Response(); $greeting = get_option('wpc2c_custom_greeting'); if (!empty($greeting)) { $twilio->addSay($greeting); } $dial = $twilio->addDial(); $dial_options = array(); if (!empty($ext)) { $dial_options = array('sendDigits' => $ext); } $dial->addNumber($number, $dial_options); $twilio->Respond(); }
} $voicemail = $dial_whom_user_or_group->voicemail; break; case 'VBX_Group': foreach ($dial_whom_user_or_group->users as $user) { $user = VBX_User::get($user->user_id); foreach ($user->devices as $device) { if ($device->is_active == 1) { $numbers[] = $device->value; } } } $voicemail = $no_answer_group_voicemail; break; default: $response->addSay('Missing user or group to dial'); break; } } else { if ($dial_whom_selector === 'number') { $numbers[] = $dial_whom_number; $voicemail = null; } else { error_log("Unexpected dial-whom-selector value of '{$dial_whom_selector}'"); } } /* Grab current state of applet */ if (isset($_COOKIE[DIAL_COOKIE])) { $stateString = str_replace(', $Version=0', '', $_COOKIE[DIAL_COOKIE]); $state = json_decode($stateString, true); if (is_object($state)) {
<?php require_once dirname(__FILE__) . '/../../lib/dopplr.php'; $user = OpenVBX::getCurrentUser(); $dopplr_token = PluginData::get("dopplr_token_{$user->id}", ""); $dopplr = new Dopplr($dopplr_token); $response = new Response(); $response->addSay($dopplr->timezone()); $response->addRedirect(AppletInstance::getDropZoneUrl('next')); $response->Respond();
$numDigits = 1; foreach ($keys as $key) { if (strlen($key) > $numDigits) { $numDigits = strlen($key); } } if ($digits !== false) { if (!empty($menu_items[$digits])) { $selected_item = $menu_items[$digits]; } else { if ($invalid_option) { $verb = AudioSpeechPickerWidget::getVerbForValue($invalid_option, null); $response->append($verb); $response->addRedirect(); } else { $response->addSay('You selected an incorrect option.'); $response->addRedirect(); } $response->Respond(); exit; } } if (!empty($selected_item)) { $response->addRedirect($selected_item); $response->Respond(); exit; } $gather = $response->addGather(compact('numDigits')); $verb = AudioSpeechPickerWidget::getVerbForValue($prompt, null); $gather->append($verb); // Infinite loop
// Using Say, Dial, and Play $r = new Response(); $r->append(new Say("Hello World", array("voice" => "man", "language" => "fr", "loop" => "10"))); $r->append(new Dial("4155551212", array("timeLimit" => "45"))); $r->append(new Play("http://www.mp3.com")); $r->Respond(); /* outputs: <Response> <Say voice="man" language="fr" loop="10">Hello World</Say> <Play>http://www.mp3.com</Play> <Dial timeLimit="45">4155551212</Dial> </Response> */ // The same XML can be created above using the convencience methods $r = new Response(); $r->addSay("Hello World", array("voice" => "man", "language" => "fr", "loop" => "10")); $r->addDial("4155551212", array("timeLimit" => "45")); $r->addPlay("http://www.mp3.com"); //$r->Respond(); // ======================================================================== // Gather, Redirect $r = new Response(); $g = $r->append(new Gather(array("numDigits" => "1"))); $g->append(new Say("Press 1")); $r->append(new Redirect()); //$r->Respond(); /* outputs: <Response> <Gather numDigits="1"> <Say>Press 1</Say> </Gather>
<?php require_once dirname(__FILE__) . '/../../lib/dopplr.php'; $user = OpenVBX::getCurrentUser(); $dopplr_token = PluginData::get("dopplr_token_{$user->id}", ""); $dopplr = new Dopplr($dopplr_token); $response = new Response(); $response->addSay($dopplr->name() . ' ' . $dopplr->status()); $response->addRedirect(AppletInstance::getDropZoneUrl('next')); $response->Respond();
<?php $response = new Response(); $url = AppletInstance::getValue('url'); $next = AppletInstance::getDropZoneUrl('next'); $fallback = AppletInstance::getDropZoneUrl('fallback'); $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $url); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl_handle); curl_close($curl_handle); if (empty($result)) { $response->addSay('that didnt work'); $response->addRedirect($fallback); $response->Respond(); } else { $response->addSay($result); $response->addRedirect($next); $response->Respond(); }
<?php require_once dirname(__FILE__) . '/../../lib/dopplr.php'; $user = OpenVBX::getCurrentUser(); $dopplr_token = PluginData::get("dopplr_token_{$user->id}", ""); $dopplr = new Dopplr($dopplr_token); $response = new Response(); $response->addSay($dopplr->local_time()); $response->addRedirect(AppletInstance::getDropZoneUrl('next')); $response->Respond();
<?php define('IS_DEV', true); require_once 'twilio.php'; if (IS_DEV) { require_once 'twillip.php'; Twillip::Start(); } $r = new Response(); if (isset($_REQUEST['Caller'])) { $r->addSay('This app uses Twillip for obviously awesome reasons!'); $r->addPlay('funky-beats.mp3', array('loop' => 3)); $r->addRedirect('/doesntexist.php'); } else { $r->addSay('Oh no! I didn\'t get sent a phone number! Who in blue blazes are you?'); $r->addSay('This line will generate a PHP warning now: ' . $_REQUEST['Caller']); } $r->respond(); if (IS_DEV) { Twillip::End(); }