Skip to content

Instantly share code, notes, and snippets.

@coderforhire
Created July 6, 2012 17:10
Show Gist options
  • Save coderforhire/3061385 to your computer and use it in GitHub Desktop.
Save coderforhire/3061385 to your computer and use it in GitHub Desktop.
def create
@receive_text = ReceiveText.new
@receive_text.body = params[:Body]
@receive_text.to = params[:To]
@receive_text.from = params[:From]
@user = User.find_by_phone("#{@receive_text.to}")
respond_to do |format|
if @receive_text.save
twilio_sid = "asdf2"
twilio_token = "asef"
@twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token
@twilio_client.account.sms.messages.create(
:from => "#{@receive_text.to}",
:to => "#{@user.forwarding_phone_number}", #forwarding number
:body => "#{@receive_text.body} from #{@receive_text.from}"
)
else
format.html { render action: "new" }
format.json { render json: @receive_text.errors, status: :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment