1.0.5 • Published 7 years ago
sms-ir v1.0.5
sms-ir-nodejs 
SMS.ir sms provider nodejs module
Install
# with npm
$ npm install --save sms-irUsage
As early as possible in your application.
APIKEY and SECRETKEY
first of all you should get api key and secret key from sms.ir.
Token
then you should get token with this code
APIKEYyour apiKeySECRETKEYyour secretKey
const {Token} = require('sms-ir')
const token = new Token();
const result = await token.get(APIKEY, SECRETKEY) // don't forget to write awaitnow you can use sms.ir api
Verification Code
now with token you can send verification code
tokenResulttoken get with Token classPHONENUMBERis user phonenumberCODEgenerated code
const {Token,VerificationCode} = require('sms-ir')
const token = new Token();
const verificationCode = new VerificationCode();
// your code
// when you need to use
const tokenResult = await token.get(APIKEY, SECRETKEY) // don't forget to write await
const verificationResult = await verificationCode.send(tokenResult, PHONENUMBER, CODE) // don't forget to write awaitexample
const {Token,VerificationCode} = require('sms-ir')
const token = new Token();
const verificationCode = new VerificationCode();
// your code
// when you need to use
const tokenResult = await token.get(APIKEY, SECRETKEY) // don't forget to write await
const verificationResult = await verificationCode.send(tokenResult, '09xxxxxxxxx', 12345) // don't forget to write awaitDefault Message
now with token you can send Message
tokenResulttoken get with Token classPHONENUMBERarray of user phone numbers only array you must send as parameterMESSAGEarray of message you should send as parameterLINENUMBERyour line number for sending
const {Token,Message} = require('sms-ir')
const token = new Token();
const message = new Message();
// your code
// when you need to use
const tokenResult = await token.get(APIKEY, SECRETKEY) // don't forget to write await
const messageResult = await message.send(tokenResult, PHONENUMBER, MESSAGE, LINENUMBER) // don't forget to write awaitexample
const {Token,Message} = require('sms-ir')
const token = new Token();
const message = new Message();
// your code
// when you need to use
const tokenResult = await token.get(APIKEY, SECRETKEY) // don't forget to write await
const messageResult = await message.send(tokenResult, ['09xxxxxxxxx'], ['message'], 'xxxxxxxxxxxxx') // don't forget to write await