Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Download the helper library from https://www.twilio.com/docs/node/install
- // Your Account Sid and Auth Token from twilio.com/console
- // DANGER! This is insecure. See http://twil.io/secure
- const accountSid = '<Redacted>'; // IMPORTANT! Follow the instructions above to get this, and replace <Redacted>
- const authToken = '<Redacted>'; // IMPORTANT! Follow the instructions above to get this, and replace <Redacted>
- const client = require('twilio')(accountSid, authToken);
- const http = require('http');
- const url = require('url');
- const requestListener = function (req, res) {
- res.writeHead(200);
- res.end('Hello, World!');
- if(req.url !== '/favicon.ico') {
- const queryObject = url.parse(req.url, true).query;
- if('title' in queryObject) {
- var body = queryObject.title;
- } else {
- var body = "Item Alert";
- }
- client.messages
- .create({
- body: body,
- from: '+<Redacted>', // IMPORTANT! Put your twilio phone number here, replacing <Redacted>
- to: '+<Redacted>' // IMPORTANT! Put your phone number here, replacing <Redacted>
- })
- .then(message => console.log(message.sid));
- }
- }
- const server = http.createServer(requestListener);
- server.listen(8080);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement