Created
March 21, 2014 15:16
-
-
Save kwhinnery/9688560 to your computer and use it in GitHub Desktop.
1.) create a directory, go into it. 2.) npm install twilio gopher 2.5) mkdir views && touch views/index.ejs 2.75) copy in code below 3.) run app with node app.js 4.) open localhost:3000/test in a browser 5.) execute node call.js in the terminal
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
var app = require('gopher'), | |
twilio = require('twilio'); | |
app.get('/test', function(request, response) { | |
var capability = new twilio.Capability(); | |
capability.allowClientIncoming('default_client'); | |
response.render('index', { | |
token: capability.generate() | |
}); | |
}); |
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
var client = require('twilio')(); | |
client.makeCall({ | |
to:'client:default_client', | |
from:'+16122554791', | |
url:'http://demo.kevinwhinnery.com/zelda.php' | |
}, function(err, response) { | |
err && console.error(err); | |
response && console.log(response); | |
}); |
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> | |
<meta charset="utf-8"> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Twilio Client</title> | |
</head> | |
<body> | |
This browser page will answer right away on an incoming call | |
<script src="//static.twilio.com/libs/twiliojs/1.1/twilio.min.js"></script> | |
<script> | |
Twilio.Device.setup('<%= token %>'); | |
Twilio.Device.incoming(function(connection) { | |
connection.accept(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment