Skip to content

Instantly share code, notes, and snippets.

@stefanobernardi
Created February 7, 2012 03:11
Show Gist options
  • Save stefanobernardi/1756903 to your computer and use it in GitHub Desktop.
Save stefanobernardi/1756903 to your computer and use it in GitHub Desktop.
Sinatra rocks
require 'rubygems'
require 'sinatra' # it's all about you
# require 'stripe' -> stripe for payments
require 'twilio-ruby' #-> twilio to send sms
# require 'mail' -> with this I can send email
# return some json stuff
get "/" do
content_type :json
# I do some pretty cool stuff here.
cool_stuff.to_json
end
# receive a post request and send me an sms with the body of the request and the sender's number
post "/stefano/sms" do
@client = Twilio::REST::Client.new TWILIOSID, TWILIOTOKEN
@client.account.sms.messages.create(
:from => "+1xxxyyyzzzzz",
:to => '+1xxxyyyxxxx',
:body => params[:from] + " sent: " + params[:body]
)
end
# way more cool stuff over here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment