This repository has been archived by the owner on Mar 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d92ad78
Showing
9 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'http://rubygems.org' | ||
gem 'sinatra' | ||
gem 'twilio-ruby' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
builder (3.0.0) | ||
json (1.6.5) | ||
jwt (0.1.4) | ||
json (>= 1.2.4) | ||
multi_json (1.0.4) | ||
rack (1.4.0) | ||
rack-protection (1.2.0) | ||
rack | ||
sinatra (1.3.2) | ||
rack (~> 1.3, >= 1.3.6) | ||
rack-protection (~> 1.2) | ||
tilt (~> 1.3, >= 1.3.3) | ||
tilt (1.3.3) | ||
twilio-ruby (3.5.0) | ||
builder (>= 2.1.2) | ||
jwt (>= 0.1.2) | ||
multi_json (>= 1.0.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
sinatra | ||
twilio-ruby |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load 'twilio-say.rb' | ||
require 'sinatra' | ||
|
||
get '/call/:number' do | ||
"""Calls a phone number, plays some sad Vader.""" | ||
Caller.new("http://#{request.host}:#{request.port.to_s}").dial(params[:number]) | ||
"Now dialing #{params[:number]}..." | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load 'twilio-say.rb' | ||
require 'sinatra' | ||
|
||
get '/call/:number' do | ||
"""Calls a phone number, plays some sad Vader.""" | ||
Caller.new("http://#{request.host}:#{request.port.to_s}").dial(params[:number]) | ||
"Now dialing #{params[:number]}..." | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require './app.rb' | ||
run Sinatra::Application |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Response> | ||
<Play>http://m.friendfeed-media.com/57d6847c57fc04e8d640cea86741c147461cfa38</Play> | ||
</Response> |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'twilio-ruby' | ||
|
||
class Caller | ||
""" | ||
Twilio API phone caller / SMS dialer. | ||
Darth Vader is gonna call and let me know when I hit the wrong key in vim. | ||
""" | ||
def initialize(hostname) | ||
""" | ||
For this to work you'll need to host a valid TwiML call script at hostname/public/twiml/call.xml. | ||
""" | ||
@client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], | ||
ENV['TWILIO_AUTH_TOKEN'] | ||
|
||
@from = @client.account.incoming_phone_numbers.list.first.phone_number | ||
@url = hostname | ||
end | ||
|
||
def sms(to_number, message) | ||
@client.account.sms.messages.create( | ||
:from => @from, | ||
:to => "+1" + to_number.to_s, | ||
:body => message.to_s) | ||
end | ||
|
||
def dial(to_number) | ||
@client.account.calls.create( | ||
:from => @from, | ||
:to => "+1" + to_number.to_s, | ||
:url => @url + "/twiml/call.xml", | ||
:method => 'GET' | ||
) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'twilio-ruby' | ||
|
||
class Caller | ||
""" | ||
Twilio API phone caller / SMS dialer. | ||
|
||
Darth Vader is gonna call and let me know when I hit the wrong key in vim. | ||
""" | ||
def initialize(hostname) | ||
""" | ||
For this to work you'll need to host a valid TwiML call script at hostname/public/twiml/call.xml. | ||
""" | ||
@client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], | ||
ENV['TWILIO_AUTH_TOKEN'] | ||
|
||
@from = @client.account.incoming_phone_numbers.list.first.phone_number | ||
@url = hostname | ||
end | ||
|
||
def sms(to_number, message) | ||
@client.account.sms.messages.create( | ||
:from => @from, | ||
:to => "+1" + to_number.to_s, | ||
:body => message.to_s) | ||
end | ||
|
||
def call(to_number) | ||
@client.account.calls.create( | ||
:from => @from, | ||
:to => "+1" + to_number.to_s, | ||
:url => @url + "/twiml/call.xml", | ||
:method => 'GET' | ||
) | ||
end | ||
end |
d92ad78
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is for @jetpackjarrett