Skip to content

Instantly share code, notes, and snippets.

@christiangenco christiangenco/twilio.js
Last active Oct 30, 2015

Embed
What would you like to do?
// gist_id: 5dd142a99f1c82cbfc94
// hook_url: https://hook.io/christiangenco/twilio
// url: http://sms.gen.co/?body="hi"
module['exports'] = function(hook) {
var client = require('twilio')(hook.env['TWILIO_SID'], hook.env['TWILIO_AUTH']);
client.sendMessage({
// to: hook.params.to || '+18177977334',
to: '+18177977334',
from: '+18176685965',
body: 'hook.io: ' + hook.params.body
}, function(err, res) {
if (!err) {
// ex: http://www.twilio.com/docs/api/rest/sending-sms#example-1
hook.res.end(JSON.stringify(res, true, 2));
} else {
hook.res.end(JSON.stringify(err, true, 2));
}
});
//hook.res.write(JSON.stringify(hook.params, true, 2))
//hook.res.write(JSON.stringify(hook.env['TWILIO_SID'], true, 2));
// hook.res.end(JSON.stringify(hook.params), true, 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.