Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def confirm
- from_phone_number = params['From']
- @registration = Registration.find_by_phone_number(from_phone_number)
- @content = params['Body']
- @twilio_client = Twilio::REST::Client.new(
- TWILIO_SID,
- TWILIO_AUTH
- )
- if @registration && @content == "YES"
- @registration.confirmed = true
- @registration.save
- @twilio_client.account.sms.messages.create(
- :from => TWILIO_NUMBER,
- :to => "+1#{from_phone_number}",
- :body => "Your registration has been confirmed!"
- )
- else
- @twilio_client.account.sms.messages.create(
- :from => TWILIO_NUMBER,
- :to => "+1#{from_phone_number}",
- :body => "Could not confirm your registration."
- )
- end
- render :text => "OK"
- end
Add Comment
Please, Sign In to add comment