Created
February 7, 2012 03:11
-
-
Save stefanobernardi/1756903 to your computer and use it in GitHub Desktop.
Sinatra rocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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