Skip to content

Commit

Permalink
Added conferencing suppport
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Conroy committed Nov 30, 2009
1 parent 4d041dd commit 975a7bb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 25 deletions.
File renamed without changes.
48 changes: 28 additions & 20 deletions example-twiml.php → example_twiml.php
Expand Up @@ -7,18 +7,6 @@
USAGE:
To create TwiML, you will make new TwiML verbs and nest them inside another
TwiML verb. Convenience methods are provided to simplify TwiML creation.
SUPPORTED VERBS:
Response
Say
Play
Dial
Gather
Hangup
Redirect
Record
Pause
Number
*/

include ('twilio.php');
Expand All @@ -30,13 +18,13 @@
"language" => "fr", "loop" => "10")));
$r->append(new Dial("4155551212", array("timeLimit" => "45")));
$r->append(new Play("http://www.mp3.com"));
//$r-> Respond();
$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>
<Say voice="man" language="fr" loop="10">Hello World</Say>
<Play>http://www.mp3.com</Play>
<Dial timeLimit="45">4155551212</Dial>
</Response>
*/

Expand All @@ -46,15 +34,15 @@
"loop" => "10"));
$r->addDial("4155551212", array("timeLimit" => "45"));
$r->addPlay("http://www.mp3.com");
//$r-> Respond();
//$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();
//$r->Respond();


/* outputs:
Expand All @@ -72,7 +60,7 @@
$say = new Say("Press 1");
$r->append($say);
$r->append($say);
//$r-> Respond();
//$r->Respond();


/*
Expand All @@ -82,6 +70,26 @@
</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
Expand All @@ -92,7 +100,7 @@
$redirect = new Redirect();
$redirect->set("crazy","delicious");
$r->append($redirect);
$r-> Respond();
//$r-> Respond();

/*
<Response>
Expand Down
File renamed without changes.
20 changes: 15 additions & 5 deletions twilio.php
Expand Up @@ -221,7 +221,7 @@ private function encode($t)
/*
* addAttributes
* $attr : A key/value array of attributes to be added
* $valid : A key/value array containging the accepted attributes
* $valid : A key/value array containging the accepted attributes
* for this verb
* Throws an exception if an invlaid attribute is found
*/
Expand Down Expand Up @@ -255,8 +255,7 @@ function append($verb) {
/*
* set
* $attr : An attribute to be added
* $valid : The attrbute value
* for this verb
* $valid : The attrbute value for this verb
* No error checking here
*/
function set($key, $value){
Expand Down Expand Up @@ -299,12 +298,16 @@ function addRedirect($body=NULL, $attr = array()){
function addPause($attr = array()){
return self::append(new Pause($attr));
}

function addConference($body=NULL, $attr = array()){
return self::append(new Conference($body, $attr));
}


/*
* write
* Output the XML for this verb and all it's children
* $parent: This verb's parent verb
* $parent: This verb's parent verb
* $writeself : If FALSE, Verb will not output itself,
* only its children
*/
Expand Down Expand Up @@ -389,7 +392,7 @@ class Dial extends Verb {
protected $valid = array('action','method','timeout','hangupOnStar',
'timeLimit','callerId');

protected $nesting = array('Number');
protected $nesting = array('Number','Conference');

}

Expand Down Expand Up @@ -438,6 +441,13 @@ class Number extends Verb {

}

class Conference extends Verb {

protected $valid = array('muted','beep','startConferenceOnEnter',
'endConferenceOnExit','waitUrl','waitMethod');

}

// Twilio Utility function and Request Validation
// ========================================================================

Expand Down

0 comments on commit 975a7bb

Please sign in to comment.