Created
April 20, 2014 01:38
-
-
Save RobSpectre/11102660 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 http = require('http'), | |
| twilio = require('twilio'); | |
| http.createServer(function (req, res) { | |
| //Create TwiML response | |
| var twiml = new twilio.TwimlResponse(); | |
| twiml.record(); | |
| res.writeHead(200, {'Content-Type': 'text/xml'}); | |
| res.end(twiml.toString()); | |
| }).listen(1337, '127.0.0.1'); | |
| console.log('TwiML servin\' server running at http://127.0.0.1:1337/'); |
This file contains hidden or 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 the Twilio module and create a REST client | |
| var client = require('twilio')('ACCOUNT_SID', 'AUTH_TOKEN'); | |
| //Place a phone call, and respond with TwiML instructions from the given URL | |
| client.makeCall({ | |
| to:'+16515556677', // Number you want to call first | |
| from: '+14506667788', // Number you want to call second | |
| url: 'http://[INSERT URL TO SERVER ABOVE]', // This will connect over the public Internet to the server above. | |
| ifMachine: true | |
| }, function(err, responseData) { | |
| //executed when the call has been initiated. | |
| console.log(responseData.from); // outputs "+14506667788" | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment