diff --git a/README.md b/README.md index eeb4bd2..61c1d70 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,38 @@ Edit `config/packages/travisjryan/twilio` with your appropriate Twilio settings Sending a SMS Message - `Twilio::message('+18085551212', 'Pink Elephants and Happy Rainbows');` +```php + +``` Creating a Call - `Twilio::call('+18085551212', 'http://foo.com/call.xml');` +```php + +``` + +Generating TwiML + +```php +say('Hello'); + $message->play('https://api.twilio.com/cowbell.mp3', array('loop' => 5)); +}); + +print $twiml; +?> +``` ### License diff --git a/src/Travisjryan/Twilio/Twilio.php b/src/Travisjryan/Twilio/Twilio.php index f103867..758ea26 100644 --- a/src/Travisjryan/Twilio/Twilio.php +++ b/src/Travisjryan/Twilio/Twilio.php @@ -30,8 +30,23 @@ public function call($to, $url, $options=array(), $from=null) { $options); } + public function twiml($callback) + { + $message = new \Services_Twilio_Twiml(); + + if( $callback instanceof \Closure ) { + call_user_func($callback, $message); + } else { + throw new \InvalidArgumentException("Callback is not valid."); + } + + return $message->__toString(); + + } + private function getTwilio() { return new \Services_Twilio($this->config['sid'], $this->config['token']); } + } \ No newline at end of file