Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Created June 1, 2012 10:27
Show Gist options
  • Select an option

  • Save stevegraham/2851034 to your computer and use it in GitHub Desktop.

Select an option

Save stevegraham/2851034 to your computer and use it in GitHub Desktop.
Proposed node.js interface
var Twilio = require('twilio-js');
Twilio.AccountSid = "xxxxxxxxxxxxxxxxxxxxxx";
Twilio.AuthToken = "xxxxxxxxxxxxxxxxxxxxxx";
Twilio.SMS.create({from: "+12125550000", to: "+16465551234", body: "OMG, my app can text!"}, function (err, res) {
// err is an Error object or null
// res is a an object containing the response e.g.
// { sid: "SMxxxxxxxxxxxxxxxxxxxxxxx", body: "OMG, my app can text!", ... }
// res has function properties to allow you to act on that resource
// e.g. res.destroy() to delete it (where applicable)
})
// You can find resources directly by their SID
Twilio.SMS.find('SMxxxxxxxxxxxxxxxxxxxxxxxxx', function(err, res) {
// err is an Error object or null
// res is a an object containing the response e.g.
// { sid: "SMxxxxxxxxxxxxxxxxxxxxxxx", body: "OMG, my app can text!", ... }
// res has function properties to allow you to act on that resource
// e.g. res.destroy() to delete it (where applicable)
})
// You can find resources using list filters
Twilio.SMS.find({from: "+12125550000", to: "+16465551234", dateSent: "2012-01-01" }, function(err, res) {
// err is an Error object or null
// res is a an array of objects containing matching resources e.g.
// [{ sid: "SMxxxxxxxxxxxxxxxxxxxxxxx", body: "OMG, my app can text!", ... }, ...]
// members of res have function properties to allow you to act on the resource it represents
// e.g. res.destroy() to delete it (where applicable)
})
Twilio.Application.update({sid: "APxxxxxxxxxxxxxxxxxxxxxxxx", voiceUrl: "http://example.com/voice"}, function(err, res) {
// err is an Error object or null
// res is a an object containing the response e.g.
// { sid: "NOxxxxxxxxxxxxxxxxxxxxxxx", voiceUrl: "http://example.com/voice" }, ... }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment