
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
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:
@license Feel free to use or modify this lib as long as my @author tag remains @version 0.0.2 @author Alexander Zubakov developer@xinit.ru
FAQs
Simple sms.ru API implementation library
We found that libsmsru demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers