-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
73 lines (66 loc) · 2.47 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SMS API INTEGRATION</title>
</head>
<body>
<form id="form" method="post">
<br>
<input type="text" id="number" placeholder="Number of recipient"><br>
<br>
<input type="text" id="message" placeholder="Message to be sent"><br>
<br>
<input type="submit" value="Send">
</form>
<br>
<p id="output"></p>
</body>
<script type="text/javascript">
const form = document.getElementById("form");
form.addEventListener("submit",function (e){
e.preventDefault();
let number = document.getElementById("number").value;
let message = document.getElementById("message").value;
// console.log(number)
fetch("https://sms.nalosolutions.com/smsbackend/clientapi/Resl_Nalo/send-message/",{
method:"POST",
body:JSON.stringify({
"username":"kwasiTest",
"password": "qwerty",
"msisdn":number.toString(),
"message":message.toString(),
"sender_id": "kwasiTest"
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then(function (response){
return response.json();
}).then(function(data){
console.log(data);
console.log(data.status);
if(data.status == 1701){
console.log("hehe")
return alert("Success, Message Submitted Successfully.\nJob Id: "+data.job_id);
}
if(data.status == 1702){
return alert("One of the parameters was not provided or left blank.");
}
if(data.status == 1704){
return alert("Invalid message");
}
if(data.status == 1705){
return alert("Invalid destination");
}
if(data.status == 1702){
return alert("One of the parameters was not provided or left blank.");
}
if(data.status == 1702){
return alert("One of the parameters was not provided or left blank.");
}
});
})
</script>
</html>