Skip to content

Instantly share code, notes, and snippets.

@christiangenco
Last active October 30, 2015 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiangenco/5dd142a99f1c82cbfc94 to your computer and use it in GitHub Desktop.
Save christiangenco/5dd142a99f1c82cbfc94 to your computer and use it in GitHub Desktop.
// 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