Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Support object reuse when sending multiple messages.

  • Loading branch information...
commit 89db196e0edcc88cd08dd0df2448f2c90137db5a 1 parent 3fac5f0
Mark Headd mheadd authored

Showing 2 changed files with 21 additions and 1 deletion. Show diff stats Hide diff stats

  1. +19 0 examples/send-multi-message.js
  2. +2 1  lib/smsified.js
19 examples/send-multi-message.js
... ... @@ -0,0 +1,19 @@
  1 +/**
  2 + * Send multiple outbound SMS messages.
  3 + * Note - please refer to output resitrctions in the SMSified documentation.
  4 + * http://smsified.com/sms-api-documentation#output_restrictions
  5 + */
  6 +
  7 +
  8 +var sys = require('sys');
  9 +var smsified = require('../lib/smsified');
  10 +
  11 +var messages = new Array('I love Node.js', 'I love Node.js even more', 'I love Node.js the mostest');
  12 +var sms = new SMSified('username', 'password');
  13 +
  14 +for(var i=0; i<messages.length; i++) {
  15 + var options = {senderAddress: '4076541234', address: '16867541234', message: messages[i]};
  16 + sms.sendMessage(options, function(result) {
  17 + sys.puts(sys.inspect(result));
  18 + });
  19 +}
3  lib/smsified.js
@@ -9,7 +9,7 @@ SMSified = function(username, password) {
9 9 this.version = 'v1',
10 10 this.username = username;
11 11 this.password = password;
12   - this.responseBody = "";
  12 + this.responseBody;
13 13 };
14 14
15 15 // Send an outbmound SMS message.
@@ -92,6 +92,7 @@ SMSified.prototype.makeApiCall = function(method, path, callback) {
92 92
93 93 // Otherwise, return the response body.
94 94 else {
  95 + self.responseBody = "";
95 96 response.setEncoding('utf8');
96 97 response.on('data', function(chunk) {
97 98 self.responseBody += chunk;

0 comments on commit 89db196

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