public static function findApps($location) { $applications = []; $dial = new Dial(); $appurl = $dial->getApplicationUrl($location); $registry = $dial->getRegistry(); foreach ($registry as $r) { if ($dial->getApp($appurl . urlencode($r['app']))) { $applications[] = $r; } } return $applications; }
public function testDialBadAppend() { $this->setExpectedException('TwilioException'); $r = new Dial(); $r->append(new Pause()); }
function dial() { $rest_access = $this->input->get_post('rest_access'); $to = $this->input->get_post('to'); $callerid = $this->input->get_post('callerid'); if (!$this->session->userdata('loggedin') && !$this->login_call($rest_access)) { $this->response->addSay("Unable to authenticate this call.\tGoodbye"); $this->response->addHangup(); $this->response->Respond(); return; } /* Response */ log_message('info', $rest_access . ':: Session for phone call: ' . var_export($this->session->userdata('user_id'), true)); $user = VBX_User::get($this->session->userdata('user_id')); $name = ''; if (empty($user)) { log_message('error', 'Unable to find user: '******'user_id')); } else { $name = $user->first_name; } if ($this->request->Digits !== false && $this->request->Digits == 1) { $options = array('action' => site_url("twiml/dial_status") . '?' . http_build_query(compact('to')), 'callerId' => $callerid); $dial_client = false; $to = normalize_phone_to_E164($to); if (!is_numeric($to)) { //$to = htmlspecialchars($this->input->get_post('to')); // look up user by email address $user = VBX_User::get(array('email' => $this->input->get_post('to'))); if (!empty($user)) { $dial_client = true; $to = $user->id; } } if (!$dial_client) { $this->response->addDial($to, $options); } else { $dial = new Dial(NULL, $options); $dial->append(new Client($to)); $this->response->append($dial); } } else { $gather = $this->response->addGather(array('numDigits' => 1)); $gather->addSay("Hello {$name}, this is a call from v b x" . ", to accept, press 1."); } $this->response->Respond(); }
/** * Add the user's devices to a Dial Verb * Ignore non-active devices * * @param VBX_user $user * @return bool */ public function dialUser($user) { // get users devices and add all active devices to do simultaneous dialing $dialed = false; if (count($user->devices)) { $dial = new Dial(NULL, array('action' => current_url(), 'callerId' => $this->callerId)); $call_opts = array('url' => site_url('twiml/whisper?name=' . urlencode($user->first_name))); foreach ($user->devices as $device) { if ($device->is_active) { if (strpos($device->value, 'client:') !== false) { $dial->addClient(str_replace('client:', '', $device->value), $call_opts); } else { $dial->addNumber($device->value, $call_opts); } $dialed = true; break; } } } if ($dialed) { $this->response->append($dial); } return $dialed; }
$say = new Say("Press 1"); $r->append($say); $r->append($say); //$r->Respond(); /* <Response> <Say>Press 1</Say> <Say>Press 1</Say> </Response> */ // ======================================================================== // Creating a Conference Call // See the conferencing docs for more information // http://www.twilio.com/docs/api/twiml/conference $r = new Response(); $dial = new Dial(); $conf = new Conference('MyRoom', array('startConferenceOnEnter' => "true")); $dial->append($conf); $r->append($dial); $r->Respond(); /* <Response> <Dial> <Conference startConferenceOnEnter="True"> MyRoom </Conference> </Dial> </Response> */ // ======================================================================== // Set any attribute / value pair
public function testDialBadAppend() { $this->setExpectedException('PlivoException'); $r = new Dial(); $r->append(new Wait()); }
<?php /* The RESTXML PHP Response Library makes it easy to write RESTXML without having to touch XML. Error checking is built in to help preventing invalid markup. USAGE: To create RESTXML, you will make new RESTXML grammar and nest them inside another RESTXML verb. Convenience methods are provided to simplify RESTXML creation. */ include '../plivohelper.php'; // ======================================================================== // Using Speak, Dial, and Play $r = new Response(); $r->append(new Speak("Hello World", array("loop" => "10"))); $g = new Dial(array("timeLimit" => "45")); $g->append(new Number("4155551212")); $r->append($g); $r->append(new Play("http://www.mp3.com")); $r->Respond(); /* outputs: <Response> <Speak loop="10">Hello World</Speak> <Dial timeLimit="45"> <Number>4155551212</Number> </Dial> <Play>http://www.mp3.com</Play> </Response> */ // The same XML can be created above using the convencience methods $r = new Response();
}); $this->stasisClient->on("message", function ($message) { $this->stasisLogger->notice("channelStorage: " . print_r($this->channelStorage, TRUE)); $event = json_decode($message->getData()); $this->stasisLogger->notice('Received event: ' . $event->type); $this->stasisEvents->emit($event->type, array($event)); }); } catch (Exception $e) { echo $e->getMessage(); exit(99); } } public function execute() { try { $this->stasisClient->open(); $this->stasisLoop->run(); } catch (Exception $e) { echo $e->getMessage(); exit(99); } } } $basicAriClient = new Dial("stasis-dial"); $basicAriClient->stasisLogger->info("Starting Stasis Program... Waiting for handshake..."); $basicAriClient->StasisAppEventHandler(); $basicAriClient->stasisLogger->info("Initializing Handlers... Waiting for handshake..."); $basicAriClient->StasisAppConnectionHandlers(); $basicAriClient->stasisLogger->info("Connecting... Waiting for handshake..."); $basicAriClient->execute(); exit(0);