-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsendSMS.js
101 lines (91 loc) · 2.47 KB
/
sendSMS.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var debug = require('debug')('SMS:SendMail');
var smsConfig = {
'host': 'info.bulksms-service.com',
'path': 'http://info.bulksms-service.com/WebServiceSMS.aspx',
'userName': 'T2015122802',
'password': 'HZTc85Cj5p',
'senderID': 'JSWCMT',
'test': true
};
// var smsConfig = {
// 'host': 'hp.bulksms1.com',
// 'path': '/sms/user/urlsms.php',
// 'userName': 'HP1186',
// 'password': 'Mc*vc52',
// 'senderID': '060000',
// 'test': true
// };
// var smsConfig = {
// 'host': 'hp.bulksms1.com',
// 'path': '/sms/user/urlsms.php',
// 'userName': 'HP1186',
// 'password': 'Mc*vc52',
// 'senderID': '060000',
// 'test': true
// };
// var data = {
// 'to': '9427593195',
// 'content': 'CLM C30011601080008 of 30 tons with truck no GJ-09-2515 for A30011601080019 has been Rejected'
// };
// sendSMS(data, function(vres) {
// console.log("sendSMS", vres);
// });
function sendSMS(data, cb) {
var http = require('http');
//var path = smsConfig.path + "?username=" + smsConfig.userName + "&pass=" + smsConfig.password + "&senderid=" + smsConfig.senderID + "&message=" + data.content + "&dest_mobileno=" + data.to + "&response=Y";
var path = smsConfig.path + "?User=" + smsConfig.userName + "&passwd=" + smsConfig.password + "&mobilenumber=" + data.to + "&message=" + data.content + "&sid=" + smsConfig.senderID + "&mtype=N";
console.log(path);
var options = {
host: smsConfig.host,
path: encodeURI(path)
};
if (smsConfig.test === false) {
http.get(options, function(res) {
if (res.statusCode == 200) {
if (cb != undefined) {
cb({
status: true
});
} else {
console.log(responseStatus.message);
}
} else {
if (cb != undefined) {
console.log(res.statusCode);
cb({
status: false
});
} else {
console.log(err);
}
}
//console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
//console.log("Got error: " + e.message);
if (cb != undefined) {
console.log(e);
cb({
status: false
});
} else {
console.log(err);
}
});
} else {
cb({
status: true
});
}
}
module.exports = {
sendSMS: sendSMS,
smsConfig: smsConfig
};
// {
// 'host': 'hp.bulksms1.com',
// 'path': '/sms/user/urlsms.php',
// 'userName': 'HP1186',
// 'password': 'Mc*vc52',
// 'senderID': '060000',
// 'test': true
// }