コード例 #1
0
ファイル: test_twiml.php プロジェクト: hellobhanu/TxtConnect
 public function testDialBadAppend()
 {
     $this->setExpectedException('TwilioException');
     $r = new Dial();
     $r->append(new Pause());
 }
コード例 #2
0
ファイル: twiml.php プロジェクト: JeffaCubed/OpenVBX
 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();
 }
コード例 #3
0
 public function testDialBadAppend()
 {
     $this->setExpectedException('PlivoException');
     $r = new Dial();
     $r->append(new Wait());
 }
コード例 #4
0
$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
// You may want to add an attribute to a verb that the library does not
// support. This can be accomplished by putting __ in front o the
コード例 #5
0
/*
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();
$r->addSpeak("Hello World", array("loop" => "10"));