Created
February 12, 2010 11:21
-
-
Save kyleconroy/302481 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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