Created
May 4, 2011 06:42
-
-
Save rahims/954842 to your computer and use it in GitHub Desktop.
Code to send an SMS using the Twilio API in Ruby. Written by Andrés Corvetto (not me, Rahim Sonawalla). Full blog post here: http://www.twilio.com/blog/2011/05/andres-corvetto-wins-our-twiliohardware-developer-contest.html
This file contains 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
require 'twiliolib' | |
# Twilio REST API version | |
API_VERSION = '2010-04-01' | |
# Twilio AccountSid and AuthToken | |
ACCOUNT_SID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
ACCOUNT_TOKEN = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' | |
FROM_ID = 'xxx-xxx-xxx'; | |
CALLER_ID = 'yyy-yyy-yyy'; | |
account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN) | |
body= 'Intruder alert! http://10.10.10.10/alert/'+ARGV[0] | |
puts 'Sending SMS:' + body | |
d = { | |
'From' => FROM_ID, | |
'To' => CALLER_ID, | |
'Body' => body, | |
} | |
resp = account.request("/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages", 'POST', d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, Unfortunately this code interface has been deprecated with version 3 of the twilio-ruby gem. The good news is the new interface is much simpler.
Here is a working example using the new interface: