Last active
February 7, 2017 15:19
-
-
Save pebblexe/7574a9e868894865b09220deb5af83bd 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
var q = require('q'); | |
var twilio = require('twilio'); | |
var http = require('http'); | |
var qs = require('querystring'); | |
var express = require('express'); | |
var app = express(); | |
var accountSid = 'A'; // Your Account SID from www.twilio.com/console | |
var authToken = '4'; // Your Auth Token from www.twilio.com/console | |
var deferred = q.defer(); | |
var client = twilio(accountSid, authToken); | |
app.get('/', function(req, res){ | |
console.log("req.query",req.query); | |
// var POST = qs.parse(body); | |
client.messages.create({ | |
to: "+14...", | |
from: "+18...", | |
body: "Test 1", | |
}, function (err, message) { | |
if(err){ | |
console.error("Unable to sendMessage with twilio:", JSON.stringify(err, null, 2)); | |
console.log("message",message); | |
return deferred.reject(err); | |
} | |
console.log('sendMessage with twilio: ' + message.sid); | |
deferred.resolve({ | |
server: 'respond with a resource SMS', | |
twilioMessage: message.sid | |
}); | |
}); | |
}); | |
app.listen(80); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment