Permalink
Browse files

Added conferencing suppport

  • Loading branch information...
1 parent 4d041dd commit 975a7bbc67ed69337f4ef1c0aaaa9836d1b8e684 Kyle Conroy committed Nov 30, 2009
File renamed without changes.
@@ -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');
@@ -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>
*/
@@ -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:
@@ -72,7 +60,7 @@
$say = new Say("Press 1");
$r->append($say);
$r->append($say);
- //$r-> Respond();
+ //$r->Respond();
/*
@@ -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
@@ -92,7 +100,7 @@
$redirect = new Redirect();
$redirect->set("crazy","delicious");
$r->append($redirect);
- $r-> Respond();
+ //$r-> Respond();
/*
<Response>
File renamed without changes.
View
@@ -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
*/
@@ -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){
@@ -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
*/
@@ -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');
}
@@ -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
// ========================================================================

0 comments on commit 975a7bb

Please sign in to comment.