Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. gem 'twilio-ruby'
  2.  
  3. class TwilioController < ApplicationController
  4.  
  5. def index
  6.  
  7. end
  8.  
  9. def sent_sms
  10. account_sid = "I put my ID here"
  11. auth_token = "I put my auth token here"
  12. twilio_phone_number = "xxxxxxxxx"
  13.  
  14. message_body = params["Body"]
  15. from_number = params["From"]
  16.  
  17. @client = Twilio::REST::Client.new(account_sid, auth_token)
  18. @client.account.sms.messages.create(
  19. from: "+1#{twilio_phone_number}",
  20. to: "+1#{from_number}",
  21. body: "Hey there! I got a text from you"
  22. )
  23. end
  24.  
  25. http://[yourdomain].com/Twilio/send_sms
  26.  
  27. twiml = Twilio::TwiML::Response.new do |r|
  28. r.Message "Hey there! I got a text from you."
  29. end
  30. twiml.text
  31.  
  32. <?xml version="1.0" encoding="UTF-8"?>
  33. <Response>
  34. <Message>Hey there! I got a text from you.</Message>
  35. </Response>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement