Exemplo n.º 1
0
 /**
  * Dial
  * 
  * Callback method that responds to a Twilio request and provides
  * a number for Twilio to dial.
  * 
  * Overloaded by Twilio Client integration - Twilio Client connection
  * requests automatically include the "1" Digit to immediately connect
  * the call
  *
  * @return void
  */
 public function dial()
 {
     validate_rest_request();
     $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->say("Unable to authenticate this call.\tGoodbye", $this->say_params);
         $this->response->hangup();
         $this->response->respond();
         return;
     }
     // Response
     $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;
     }
     $digits = clean_digits($this->input->get_post('Digits'));
     if ($digits !== false && $digits == 1) {
         $options = array('action' => site_url("twiml/dial_status") . '?' . http_build_query(compact('to')), 'callerId' => $callerid);
         if (filter_var($this->input->get_post('to'), FILTER_VALIDATE_EMAIL)) {
             $this->dial_user_by_email($this->input->get_post('to'), $options);
         } elseif (preg_match('|client:[0-9]{1,4}|', $this->input->get_post('to'))) {
             $this->dial_user_by_client_id($this->input->get_post('to'), $options);
         } else {
             $to = normalize_phone_to_E164($to);
             $this->response->dial($to, $options);
         }
     } else {
         $gather = $this->response->gather(array('numDigits' => 1));
         $gather->say("Hello {$name}, this is a call from VeeBee Ex, to accept, press 1.", $this->say_params);
     }
     $this->response->respond();
 }
Exemplo n.º 2
0
 function hangup_on_cancel()
 {
     _deprecated_method(__METHOD__, '1.0.4');
     validate_rest_request();
     $response = new TwimlResponse();
     $response->hangup();
     return $response->respond();
 }