Permalink
Browse files

readme update

  • Loading branch information...
1 parent 047a1b6 commit cd1f4d8520bf1f5be66d4585456b2a80db646f09 @andrewmbenton andrewmbenton committed Jul 31, 2011
Showing with 67 additions and 5 deletions.
  1. +67 −5 README.md
View
72 README.md
@@ -16,20 +16,82 @@ $ rake gem
$ gem install pkg/twilio-ruby-{version}
```
-## Some Code To Get You Started
+## Get Started With Client Capability Tokens
+
+If you just need to generate a Capability Token for use with Twilio Client, you
+can do this:
+
+``` ruby
+require 'rubygems' # not necessary with ruby 1.9 but included for completeness
+require 'twilio-ruby'
+
+# put your own account credentials here:
+account_sid = 'AC043dcf9844e13758bc3a36a84c29761'
+auth_token = '62ea81de3a5b413254eb263595357c69'
+
+# set up
+capability = Twilio::Util::Capability.new account_sid, auth_token
+
+# allow outgoing calls to an application
+capability.allow_client_outgoing 'AP89a0180a1a4ddf1da954efca349b7a20'
+
+# allow incoming calls to 'andrew'
+capability.allow_client_incoming 'andrew'
+
+# generate the token string
+@token = capability.generate
+```
+
+There is a slightly more detailed document in the
+[Capability](twilio-ruby/wiki/Capability) section of the wiki.
+
+## Getting Started with TwiML
+
+TwiML support is based on the [builder][1] library. You can construct a TwiML
+response like this:
+
+``` ruby
+require 'rubygems' # not necessary with ruby 1.9 but included for completeness
+require 'twilio-ruby'
+
+# build up a response
+response = Twilio::TwiML::Response.new do |r|
+ r.Say 'hello there', :voice => 'woman'
+ r.Dial :callerId => '+14159992222' do |d|
+ d.Client 'jenny'
+ end
+end
+
+# print the result
+puts response.text
+```
+
+This will print the following (except for the whitespace):
+
+```
+<?xml version="1.0" encoding="UTF-8"?>
+<Response>
+ <Say voice="woman">hello there</Say>
+ <Dial callerId="+14159992222">
+ <Client>jenny</Client>
+ </Dial>
+</Response>
+```
+
+## Getting Started with REST
### Setup Work
``` ruby
-require 'rubygems' # not necessary with ruby 1.9.2 but included for completeness
+require 'rubygems' # not necessary with ruby 1.9 but included for completeness
require 'twilio-ruby'
# put your own credentials here
-@account_sid = 'AC043dcf9844e04758bc3a36a84c29761'
-@auth_token = '62ea81de3a5b414154eb263595357c69'
+account_sid = 'AC043dcf9844e04758bc3a36a84c29761'
+auth_token = '62ea81de3a5b414154eb263595357c69'
# set up a client to talk to the Twilio REST API
-@client = Twilio::REST::Client.new(@account_sid, @auth_token)
+@client = Twilio::REST::Client.new account_sid, auth_token
```
### Send an SMS

0 comments on commit cd1f4d8

Please sign in to comment.