Created
October 21, 2016 19:55
-
-
Save kwhinnery/c2b2282db3031ee3bbaef1dd61c620d6 to your computer and use it in GitHub Desktop.
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 'sinatra' | |
require 'twilio-ruby' | |
sid = '' | |
tkn = '' | |
app_sid = '' | |
capability = Twilio::Util::Capability.new sid, tkn | |
capability.allow_client_outgoing(app_sid) | |
get '/token' do | |
content_type 'text/plain' | |
capability.generate | |
end | |
get '/hello' do | |
content_type 'text/xml' | |
erb :twiml | |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<h1>twilio client demo</h1> | |
<button>make call</button> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<script type="text/javascript" src="//media.twiliocdn.com/sdk/js/client/v1.3/twilio.min.js"></script> | |
<script type="text/javascript"> | |
$.get('/token').done(function(tokenString) { | |
Twilio.Device.setup(tokenString); | |
}); | |
$('button').on('click', function() { | |
Twilio.Device.connect(); | |
}); | |
</script> | |
</body> | |
</html> |
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 'twilio-ruby' | |
sid = '' | |
tkn = '' | |
client = Twilio::REST::Client.new sid, tkn | |
client.account.messages.create( | |
to: '+12063347567', | |
from: '+16513471042', | |
body: 'hey there! welcome to Twilio, I want to hang out in hong kong sometime' | |
) |
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
<Response> | |
<Say>Hello there marketing peeps! This is a Twilio Ruby app.</Say> | |
</Response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment