Skip to content

Instantly share code, notes, and snippets.

@kwhinnery
Created Oct 21, 2016
Embed
What would you like to do?
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
<!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>
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'
)
<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