Skip to content
Browse files

Support object reuse when sending multiple messages.

  • Loading branch information...
1 parent 3fac5f0 commit 89db196e0edcc88cd08dd0df2448f2c90137db5a @mheadd mheadd committed May 21, 2011
Showing with 21 additions and 1 deletion.
  1. +19 −0 examples/send-multi-message.js
  2. +2 −1 lib/smsified.js
View
19 examples/send-multi-message.js
@@ -0,0 +1,19 @@
+/**
+ * Send multiple outbound SMS messages.
+ * Note - please refer to output resitrctions in the SMSified documentation.
+ * http://smsified.com/sms-api-documentation#output_restrictions
+ */
+
+
+var sys = require('sys');
+var smsified = require('../lib/smsified');
+
+var messages = new Array('I love Node.js', 'I love Node.js even more', 'I love Node.js the mostest');
+var sms = new SMSified('username', 'password');
+
+for(var i=0; i<messages.length; i++) {
+ var options = {senderAddress: '4076541234', address: '16867541234', message: messages[i]};
+ sms.sendMessage(options, function(result) {
+ sys.puts(sys.inspect(result));
+ });
+}
View
3 lib/smsified.js
@@ -9,7 +9,7 @@ SMSified = function(username, password) {
this.version = 'v1',
this.username = username;
this.password = password;
- this.responseBody = "";
+ this.responseBody;
};
// Send an outbmound SMS message.
@@ -92,6 +92,7 @@ SMSified.prototype.makeApiCall = function(method, path, callback) {
// Otherwise, return the response body.
else {
+ self.responseBody = "";
response.setEncoding('utf8');
response.on('data', function(chunk) {
self.responseBody += chunk;

0 comments on commit 89db196

Please sign in to comment.
Something went wrong with that request. Please try again.