Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 3e9e599c345e62e798743472ba7ef19eb2e698fb Your Name committed May 18, 2011
Showing with 76 additions and 0 deletions.
  1. BIN .DS_Store
  2. +49 −0 smsified_node.js
  3. +27 −0 smsified_node_w_lib.js
BIN .DS_Store
Binary file not shown.
49 smsified_node.js
@@ -0,0 +1,49 @@
+var http = require('http');
+var express = require('express');
+var querystring = require('querystring');
+var app = express.createServer();
+
+app.configure(function(){
+ app.use(express.bodyParser());
+});
+
+app.post('/', function(req, res){
+
+ var callerID = req.body['inboundSMSMessageNotification']['inboundSMSMessage']['senderAddress'];
+ var message = req.body['inboundSMSMessageNotification']['inboundSMSMessage']['message'];
+ var my_number = '14075550100';
+ var complete_msg = "The callerID is " + callerID + " and they said " + message;
+
+ var post_data = querystring.stringify({
+ 'address' : my_number,
+ 'message': complete_msg
+ });
+
+ var post_options = {
+ host: 'api.smsified.com',
+ port: '80',
+ path: '/v1/smsmessaging/outbound/15855550100/requests',
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Content-Length': post_data.length,
+ 'Authorization':"Basic "+ new Buffer('username' + ":" + "password").toString('base64')
+ }
+ };
+
+
+ var post_req = http.request(post_options, function(res) {
+ res.setEncoding('utf8');
+ res.on('data', function (chunk) {
+ console.log('Response: ' + chunk);
+ });
+ });
+
+ // write parameters to post body
+ post_req.write(post_data);
+ post_req.end();
+ res.end();
+
+});
+
+app.listen(10056);
27 smsified_node_w_lib.js
@@ -0,0 +1,27 @@
+var sys = require('sys');
+var express = require('express');
+var app = express.createServer();
+var smsified = require('smsified');
+
+app.configure(function(){
+ app.use(express.bodyParser());
+});
+
+app.post('/', function(req, res){
+
+ var callerID = req.body['inboundSMSMessageNotification']['inboundSMSMessage']['senderAddress'];
+ var message = req.body['inboundSMSMessageNotification']['inboundSMSMessage']['message'];
+ var my_number = '14075550100';
+ var complete_msg = "The callerID is " + callerID + " and they said " + message;
+
+ var sms = new SMSified('username', 'password');
+ var options = {senderAddress: '15853260802', address: my_number, message: complete_msg};
+
+ sms.sendMessage(options, function(result) {
+ sys.puts(sys.inspect(result));
+ });
+
+ res.end();
+});
+
+app.listen(10056);

0 comments on commit 3e9e599

Please sign in to comment.