-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
36 lines (29 loc) · 898 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var express = require('express');
var router = express.Router();
var accountSid = 'ACd5e98e37663e42507bc0ae80547bda57';
var authToken = 'b2c2a1e368ea26263c72880c7c89431d';
var twilio = require('twilio');
var client = new twilio.RestClient(accountSid, authToken);
var msg = "Look Out! Something is ahead of you.";
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
function sendText(text, receiver, callback) {
client.messages.create({
body: text,
to: receiver,
from: '14154032108'
}, function (err, message) {
callback(err, message);
});
}
router.post('/', function (req, res) {
console.log(req);
var vibrate = req.body.values;
sendText(msg, '14159870073', (err, message) => {
console.log('sent text to phone');
});
res.send();
});
module.exports = router;