Skip to content

Instantly share code, notes, and snippets.

@titanous
Created January 29, 2010 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save titanous/290079 to your computer and use it in GitHub Desktop.
Save titanous/290079 to your computer and use it in GitHub Desktop.
Twilio calls from the terminal
#!/usr/bin/env ruby
require 'twiliolib'
# Twilio REST API version
API_VERSION = '2008-08-01'
# Twilio AccountSid and AuthToken
ACCOUNT_SID = 'AC79a4b3609b05ee750cf0844e330cd11b' # FAKE
ACCOUNT_TOKEN = '1d1b9c34c3a40f5c6ba501775ba1f86b' # FAKE
# Outgoing Caller ID previously validated with Twilio
CALLER_ID = '6135550812'; # FAKE
# Create a Twilio REST account object using your Twilio account ID and token
account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)
data = {
'Caller' => CALLER_ID,
'Called' => ARGV[0],
'Url' => ARGV[1],
}
resp = account.request("/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/Calls", 'POST', data)
resp.error! unless resp.kind_of? Net::HTTPSuccess
puts "code: %s\nbody: %s" % [resp.code, resp.body]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment