Node-aspsms is a project mainly written in JavaScript, based on the MIT license.
A node.js module to send SMS text messages through aspsms.com
A partial implementation of the aspsms.com XML SMS API for node.js.
sudo npm install aspsms
setDefaultOptions(options)
Sets the default optionssend(options, callback, message)
Sends a text messageshowCredits(options, callback, message)
Returns the amount of credits leftuserkey
Your ASPSMS Uesrkeypassword
Your ASPSMS passwordoriginator
Name of the senderrecipient
Mobile phone number of the recipientIf the operation was successfull the error
object passed to the callback will
be null
. If the operation fails the error object will contain an errorCode
and an errorDescription
field with values according to the aspsms.com
documentation.
Send a text message
var aspsms = require('aspsms');
aspsms.setDefaultOptions({
'userkey' : 'YOUR_ASPSMS_USERKEY',
'password' : 'YOUR_ASPSMS_PASSWORD',
'originator' : 'TestApp'
});
aspsms.send({
'recipient' : '+41555123456'
}, function (error) {
if (!error) {
console.log('Success!');
}
}, 'Hello, this is a test.');
Show how many credits you have left
var aspsms = require('aspsms');
aspsms.setDefaultOptions({
'userkey' : 'YOUR_ASPSMS_USERKEY',
'password' : 'YOUR_ASPSMS_PASSWORD',
});
aspsms.showCredits({ }, function (error, credits) {
if (!error) {
console.log('You have ' + credits + ' left');
}
});
If you don't want to use setDefaultOptions
you can pass all options in each
command.
var aspsms = require('aspsms');
aspsms.send({
'userkey' : 'YOUR_ASPSMS_USERKEY',
'password' : 'YOUR_ASPSMS_PASSWORD',
'originator' : 'TestApp',
'recipient' : '+41555123456'
}, function (error) {
if (!error) {
console.log('Success!');
}
}, 'Hello, this is a test.');