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();