Skip to content

Instantly share code, notes, and snippets.

@mheadd
Created May 12, 2011 17:51
Show Gist options
  • Select an option

  • Save mheadd/969065 to your computer and use it in GitHub Desktop.

Select an option

Save mheadd/969065 to your computer and use it in GitHub Desktop.
Node.js scripts for processing SMS delivery reports from SMSified.
var sys = require('sys');
var http = require('http');
var cradle = require('cradle');
var port = 8000;
var db = new (cradle.Connection)('http://127.0.0.1', 5984).database('smsrecords');
var server = http.createServer(function(req, res) {
req.addListener('data', function(data){
db.save(JSON.parse(data), function(err, res){
if(err) {
sys.puts('Could not save delivery record.');
}
else {
sys.puts('delivery record saved '+ res.id);
}
});
});
res.writeHead(200);
res.end();
}).listen(port);
sys.puts('Server listening on port ' + port);
var sys = require('sys');
var http = require('http');
var port = 8000;
var server = http.createServer(function(req, res) {
req.addListener('data', function(data){
var json = JSON.parse(data);
sys.puts(sys.inspect(json));
});
res.writeHead(200);
res.end();
}).listen(port);
sys.puts('Server listening on port ' + port);
@salasks

salasks commented Jun 8, 2011

Copy link
Copy Markdown

Just posting the URL to your demo video here for easy access...
http://blog.smsified.com/2011/05/video-smsified-and-couchdb-sms-awesomeness-in-5-minutes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment