- API & Docs
To complete the Twilio Ruby quickstarts, you'll need to have the following tools installed:
We'll cover the installation process for all of these dependencies.
If you are on a Mac or a Linux/Unix machine, you probably already have Ruby installed. You have Ruby installed if you type this at the command line:
ruby -v ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0]
and get any output back. If you get
ruby: command not found, follow these
instructions to install Ruby for Mac or Linux.
If you are using Windows, you should download the RubyInstaller package, which contains a complete Ruby environment.
Third party dependencies in Ruby are managed with RubyGems, a command line tool that makes it very easy to add new libraries and include them in your Ruby projects. You can check if you have RubyGems installed already by running this at the command line:
gem --version 1.8.24
If you get
gem: command not found, you can download RubyGems from their
downloads page. For Windows users,
RubyGems should be installed as a part of the RubyInstaller.
Once you have rubygems installed, installing Sinatra and twilio-ruby is a snap. Simply type this at the command line:
gem install sinatra twilio-ruby
RubyGems will take care of the rest of the work.
Let's try it out with a short test file. Open a file called test.rb and add the following:
require 'rubygems' require 'twilio-ruby' require 'sinatra' get '/' do 'Hello World! Currently running version ' + Twilio::VERSION + \ ' of the twilio-ruby library.' end
Now start up a local web server by running your
test.rb file at the command
ruby test.rb Sinatra/1.3.2 has taken the stage on 4567 for development with backup from Thin >> Thin web server (v1.4.1 codename Chromeo) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:4567, CTRL+C to stop
http://localhost:4567 in your browser. You
should see a Hello World message, with the twilio-ruby version posted.
If you received an error along the way, contact our support team with a description of what you were trying to do, what you expected to see and what actually happened, and they'll be glad to help you figure out what's going on.
Now that you've got a local environment set up, you should dive into the Quickstarts. Have fun!