Example api code for Transactional SMS in node.js

Replace user, password, msisdn, sid and message accordingly.

 

1. Below is the sample code for node.js for Single Message:

const http = require('http');
const querystring = require('querystring');

const user = 'abc';
const password = 'xyz';
const msisdn = '919898xxxxxx';
const sid = 'SenderId';
const message = 'test message';
const fl = '0';
const gwid = '2';

const params = querystring.stringify({
user,
password,
msisdn,
sid,
msg: message,
fl,
gwid,
});

const options = {
hostname: 'sms.domainadda.com',
path: '/vendorsms/pushsms.aspx?' + params,
method: 'GET',
};

const req = http.request(options, (res) => {
let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
console.log('API response:', data);
});
});

req.on('error', (error) => {
console.error('Error:', error);
});

req.end();

 

2. Below is the sample code for node.js for Multiple Messages:

const http = require('http');
const querystring = require('querystring');

const user = 'abc';
const password = 'xyz';
const msisdns = '919898xxxxxx,919898xxxxxx'; // Comma-separated list of phone numbers
const sid = 'SenderId';
const message = 'test message';
const fl = '0';
const gwid = '2';

const params = querystring.stringify({
user,
password,
msisdn: msisdns,
sid,
msg: message,
fl,
gwid,
});

const options = {
hostname: 'sms.domainadda.com',
path: '/vendorsms/pushsms.aspx?' + params,
method: 'GET',
};

const req = http.request(options, (res) => {
let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
console.log('API response:', data);
});
});

req.on('error', (error) => {
console.error('Error:', error);
});

req.end();

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Example api code for Transactional SMS in asp.net

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in php

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in ruby

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in java

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in python

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...