Skip to content

Instantly share code, notes, and snippets.

@kyleconroy
Created February 12, 2010 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleconroy/302481 to your computer and use it in GitHub Desktop.
Save kyleconroy/302481 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'twiliolib'
# Twilio REST API version
API_VERSION = '2008-08-01'
# Twilio AccountSid and AuthToken
ACCOUNT_SID = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
ACCOUNT_TOKEN = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
# Outgoing Caller ID previously validated with Twilio
CALLER_ID = 'NNNNNNNNNN';
# Create a Twilio REST account object using your Twilio account ID and token
account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)
# ===========================================================================
# 1. Initiate an outbound SMS message to 415-555-1212
# uses a HTTP POST
d = {
'From' => CALLER_ID,
'To' => '415-555-1212',
'Body' => 'Hello from Twilio',
}
resp = account.request("/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages",
'POST', d)
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