From 975a7bbc67ed69337f4ef1c0aaaa9836d1b8e684 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 30 Nov 2009 11:56:22 -0800 Subject: [PATCH] Added conferencing suppport --- example-rest.php => example_rest.php | 0 example-twiml.php => example_twiml.php | 48 +++++++++++++++----------- example-utils.php => example_utils.php | 0 twilio.php | 20 ++++++++--- 4 files changed, 43 insertions(+), 25 deletions(-) rename example-rest.php => example_rest.php (100%) rename example-twiml.php => example_twiml.php (74%) rename example-utils.php => example_utils.php (100%) diff --git a/example-rest.php b/example_rest.php similarity index 100% rename from example-rest.php rename to example_rest.php diff --git a/example-twiml.php b/example_twiml.php similarity index 74% rename from example-twiml.php rename to example_twiml.php index 6a01371b5..fb8edfbac 100644 --- a/example-twiml.php +++ b/example_twiml.php @@ -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: - Hello World - http://www.mp3.com - 4155551212 + Hello World + http://www.mp3.com + 4155551212 */ @@ -46,7 +34,7 @@ "loop" => "10")); $r->addDial("4155551212", array("timeLimit" => "45")); $r->addPlay("http://www.mp3.com"); - //$r-> Respond(); + //$r->Respond(); // ======================================================================== // Gather, Redirect @@ -54,7 +42,7 @@ $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 @@ */ + // ======================================================================== + // 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(); + + /* + + + + MyRoom + + + + */ // ======================================================================== // Set any attribute / value pair @@ -92,7 +100,7 @@ $redirect = new Redirect(); $redirect->set("crazy","delicious"); $r->append($redirect); - $r-> Respond(); + //$r-> Respond(); /* diff --git a/example-utils.php b/example_utils.php similarity index 100% rename from example-utils.php rename to example_utils.php diff --git a/twilio.php b/twilio.php index 5c0ede641..e54e9b62f 100644 --- a/twilio.php +++ b/twilio.php @@ -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 // ========================================================================