node-alphasms

1.0.0 • Public • Published

NodeJS module for Alpha SMS service (based on https://www.npmjs.com/package/node-smsukraine)

Node module for using API of service alphasms.ua. The full list of API methods and it's params you can find here.

Installing

npm install node-alphasms

Usage

You can use two methods for setting login and pass: global and local.

With global method you can set login, pass and sms name for each request:

const SmsService = require('node-alphasms');
const sms = new SmsService({login: "my_login", pass: "my_pass", name: "my_sms_name"});
  • login - your login in the system;
  • pass - your password;
  • name - your sms name;

With local method you can set login, pass and sms name for current request

sms.status({id: "248919871", login: "my_login", pass: "my_pass"}, function(err, sms_data){
    if(err) return console.log(JSON.stringify(err));
    console.log(JSON.stringify(sms_data));
})

Methods

Send SMS

const data = {"to": "380971234567", "text": "Hello world!"}
sms.send(data, function(err, sms_data){
    if(err) return console.log(JSON.stringify(err));
    console.log(JSON.stringify(sms_data));
})

For parameter data.to you can use differen types of mobile number. For example:

  • +38 (097) 123-45-67
  • 097 123 45 67
  • 80971234567
  • etc.

With successful request you will receive message with SMS id and SMS count:

{
    "id": 123456,
    "sms_count": 2
}

Check status

sms.status(248919871, function(err, sms_data){
    if(err) return console.log("err:" + JSON.stringify(err));
    console.log(JSON.stringify(sms_data));
})

Where id - sended SMS id.

With successful request you will receive status and code:

{
    "code": 2,
    "status": "Доставлено",
    "status_time":"2015-05-10T15:06:21+0300"
}

Check balance

sms.balance(function(err, balance){
    if(err) return console.log(JSON.stringify(err));
    console.log("balance: " + balance);
})

Contacts

Bogdan Tushevskyi tushevskuy@gmail.com

Readme

Keywords

Package Sidebar

Install

npm i node-alphasms

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • copy_pastor