Skip to content

Instantly share code, notes, and snippets.

@mvilrokx
Created January 21, 2015 22:07
Show Gist options
  • Save mvilrokx/e919be7e814b142222d8 to your computer and use it in GitHub Desktop.
Save mvilrokx/e919be7e814b142222d8 to your computer and use it in GitHub Desktop.
Calling the Twilio SMS API
var twilio = {
username: <your-twilio-username>,
pwd: <your-twilio-pwd>,
phone: <your-twilio-phone-number>,
server_url: 'https://api.twilio.com/2010-04-01/Accounts/'
};
var user = {
phone: <user-phone-number>
};
if ($("#sms").is(':checked')) {
$.ajax({
type: "POST",
username: twilio.username,
password: twilio.pwd,
url: twilio.server_url + twilio.username + '/Messages.json',
data: { Body: event.target.innerText, From: twilio.phone, To: user.phone }
})
.done(function( msg ) {
console.log("Message Send");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment