Skip to content

Instantly share code, notes, and snippets.

@manlycode
Created January 18, 2012 20:50
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 manlycode/1635511 to your computer and use it in GitHub Desktop.
Save manlycode/1635511 to your computer and use it in GitHub Desktop.
class SendTextController < ApplicationController
def index
end
def send_text_message
number_to_send_to = params[:number_to_send_to]
twilio_sid = "abc123"
twilio_token = "foobar"
twilio_phone_number = "6165555555"
@twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token
@twilio_client.account.sms.messages.create(
:from => "+1#{twilio_phone_number}",
:to => number_to_send_to,
:body => "This is an message. It gets sent to #{number_to_send_to}"
)
end
end
@alexcchan
Copy link

Just ran across this old comment. The Ruby client is not (currently) thread-safe so it's probably better to keep it request scoped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment