Created
September 13, 2012 21:20
-
-
Save RobSpectre/3717756 to your computer and use it in GitHub Desktop.
Example of catching Twilio REST exceptions in Ruby - sketch, I don't actually know how this works.
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
| require 'rubygems' # not necessary with ruby 1.9 but included for completeness | |
| require 'twilio-ruby' | |
| # put your own credentials here | |
| account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
| auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' | |
| # set up a client to talk to the Twilio REST API | |
| @client = Twilio::REST::Client.new account_sid, auth_token | |
| begin | |
| @client.account.sms.messages.create( | |
| :from => '+14159341234', | |
| :to => '+16105557069', | |
| :body => 'Hey there!' | |
| ) | |
| rescue Twilio::REST::RequestError => e | |
| # do whatever you need to accept the failure gracefully | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment