npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libsmsru

v0.0.2

Published

Simple sms.ru API implementation library

Downloads

12

Readme

Simple sms.ru API library. All you basicly need is here - sending SMS and checking delivering status of sent messages.

Usage is as simple as it can be. Require library (in this example it located in ./lib/, but you can install it to your node_modules directory):

var sms = require('./lib/libsmsru');

You need to authorise with your API ID:

sms.auth('00000000-0000-0000-0000-000000000000');

or with your login and password:

sms.auth('login', 'pa$$w0rd');

Then just send SMS with text 'Пример SMS-сообщения' to number 79150000000 from sender xinit.ru:

sms.send('79150000000', 'Пример SMS-сообщения', { from: 'xinit.ru' }, onSend);

Note that in options object { from: 'xinit.ru' } you can use all parameters from sms.ru you want. Or you can just skip it and send SMS this way:

sms.send('79150000000', 'Пример SMS-сообщения', onSend);

This time SMS will be sent from default sender.

onSend is Callback function with two parameters: (err, answer). If err is null then you are lucky - your SMS has been successfully sent. If err is not null then SMS will not be delivered because of error occured while sending. You can view err.code (number error code) and err.message (human readable russian message). If err is null then answer is object like this:

{
    raw    : '100\n200007-300007\nbalance=199.03',
    smsId  : [ '200007-300007' ],
    status : '100',
    balance: '199.03'
}

raw is just raw answer from sms.ru server. You probably don't need it until you perfectly know what you are doing (you do not need it even then). smsId is array of SMS identifiers. You need it if you want to check sent SMS status. status is message sending status code. Nomally it should be always '100'. balance is you account balance in russian RUB.

When you successfully sent SMS, you probably want to know whether it came to receipient or not. You can do it simply calling one function:

sms.status('200007-300007', onStatus);

'200007-300007' is SMS identifier from onSend()'s answer.smsId array. Note that sms.status() can work only with one ID string, not with arrays.

onStatus is callback function (err, answer). If SMS can't be delivered at all (for any reason) then err will contain two fields: code (number code of error) and message (human readable error description in russian). If SMS delivered or in progress then err is null and answer is key-value object with the following parameters:

{
    raw    : '102',
    status : '102',
    message: 'Сообщение отправлено (в пути)'
}

raw is raw answer from sms.ru which you don't need until debugging purposes. status is code which shows SMS delivering status. Normally you need statuses '102' (means that SMS delivering is in progress) and '103' (means that SMS successfully delivered). message is human readable message in russian.

That's all! You can also try well commented example usecase.coffee (usecase.js if you want raw JavaScript).

If you want this library always stay actual you can:

  • donate via PayPal (more info: http://xinit.ru/)
  • use sms.ru from this access point: http://xinit.sms.ru/ (it makes no differences for you but allow me to get a little money)
  • send SMS messages with this library (here is my agent code which makes no differences for you but allow me to get a little money)
  • comment, share, spread this library
  • send issues, pull requests

@license Feel free to use or modify this lib as long as my @author tag remains @version 0.0.2 @author Alexander Zubakov [email protected]