Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c8cba521bb
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 37 lines (30 sloc) 0.886 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
require 'sinatra'
require 'yaml'
require 'twilio'

CALLER_ID = config['caller_id']

# You need to replace the entries in config.yml
# with your own twilio information like so:
#
# caller_id = your twilio phone number
# twilio_sid = your twilio sid, keep this private
# twilio_tkn = your twilio token, keep this private
#
# You can access these later with config['param']
# where param is replaced by an option in the yaml
# file.
config = YAML.load_file('./config/config.yml')

get '/' do
  haml :index
end

post '/sms' do
  Twilio.connect(config['twilio_sid'], config['twilio_tkn'])
  number = params[:number]
  message = params[:msg]

  # If you're using a twilio demo number you'll need
  # to include your twilio PIN as the first argument
  # here:
  #
  # Twilio::Sms.message(PIN, CALLER_ID, number, message)
  Twilio::Sms.message(CALLER_ID, number, message)

  redirect '/'
end
Something went wrong with that request. Please try again.