Skip to content

Instantly share code, notes, and snippets.

@thoughtpalette
Created August 6, 2014 20:19
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 thoughtpalette/47ba20ab022e49a4443e to your computer and use it in GitHub Desktop.
Save thoughtpalette/47ba20ab022e49a4443e to your computer and use it in GitHub Desktop.
Twilio API jQuery Post
// Had issues with CORS when implementing different post types and changing headers in node/express/angular.$http, this works even though it still gives me the CORS error.
$.ajax({
type: "POST",
username: "[ACCOUNT_SID]",
password: "[AUTH_TOKEN]",
url: "https://api.twilio.com/2010-04-01/Accounts/[SID_HERE]/SMS/Messages",
xhrFields: {
withCredentials: true
},
data: {
"To" : "+1312******",
"From" : "+1********",
"Body" : "your message"
},
success: function(data) {
console.log(data);
},
error: function(data) {
console.log(data);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment