Download and any version of JavaScript api helper and include your JavaScript script.
<script src="websmslk.js"> </script>
Get ready with easy initializing websmslk js
For get api key and other details SignUp On newsletters.lk and here is URL of api details https://https:app.newsletters.lk/apis
<script src="websmslk.js"> </script>
var websms=WebSMSLK({
apikey:'YOUR API KEY',
apitoken:'YOUR API TOKEN',
senderName:'WebSMS'
});
websms.SendSMS("07XXXXXXXX","Your message");
For get your own Sender Id call our support center +94-777-004416 or mail to [email protected]
websms.SendSMS("0777004416","hello my first web sms");
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Websms.lk - JavaScript SMS API</title>
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.8.10/css/mdb.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.8.10/js/mdb.min.js"></script>
<style>
body,html{
background:#eee;
}
.headerback {
background:#006ab9;
color:#fff;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<div class="row mt-2">
<div class="col-12 col-md-8 offset-md-2">
<div class="alert alert-info">
To register and get info, https://newsletters.lk
</div>
<div class="alert alert-warning">
We used jQuery for use bootsrap framework and WebSMS plugin <b>not required jQuery</b> you can use it with pure javascript
</div>
<form method="post"> <!-- FORM START YOU CAN USE POST OR GET -->
<div class="card">
<div class="card-header headerback">API DETAILS</div>
<div class="card-body">
<div class="md-form">
<input type="text" name="sender_id" id="sender_id" aria-expanded="true" value="WebSMS" focus class="form-control"/>
<label for="sender_id">Sender ID</label>
</div>
<div class="md-form">
<input type="text" name="api_key" id="api_key" class="form-control"/>
<label for="api_key">API KEY</label>
</div>
<div class="md-form">
<input type="text" name="api_token" id="api_token" class="form-control"/>
<label for="api_token">API TOKEN</label>
</div>
</div>
</div>
<div class="card mt-2">
<div class="card-header headerback">MESSAGE</div>
<div class="card-body">
<div class="md-form">
<select name="msgType" id="msgType" class="form-control">
<option value="sms">SMS</option>
<option value="voice">Voice</option>
<option value="mms">MMS</option>
<option value="flash">Flash</option>
<option value="unicode">Unicode</option>
<option value="whatsapp">Whats APP</option>
</select>
</div>
<div class="md-form" id="file_sel" style="display:none;">
<input type="text" class="form-control" name="file" id="file" />
<label for="file">File URL For Voice,MMS,Whatsapp</label>
</div>
<div class="md-form">
<input type="text" class="form-control" name="language" id="language" />
<label for="language">Laguage - Default empty</label>
</div>
<div class="md-form" id="voice_duration" style="display:none;">
<input type="text" class="form-control" name="duration" id="duration" />
<label for="duration">Duration of voice msg</label>
</div>
<div class="md-form">
<input type="datetime" class="form-control" name="scheduledate" id="scheduledate"/>
<label for="scheduledate">Schedule date Default instant</label>
</div>
<hr />
<div class="md-form">
<input type="text" class="form-control" name="mobile" id="mobile" />
<label for="mobile">Mobile Number</label>
<small>For Sri Lanka 07XXXXXXXX For Other Countries Enter With Country Code</small>
</div>
<div class="md-form">
<textarea name="text" id="text" cols="30" rows="10" class="form-control" ></textarea><br />
<label for="text">Message</label>
<small>For Type Sinhala Or Tamil Select Unicode To Message Type</small>
</div>
<hr />
<div class="md-form">
<div class="row">
<div class="col">
<button type="button" id="btn_json" class="btn btn-secondary btn-lg btn-block">Send - Ajax + JSON </button>
</div>
</div>
</div>
</div>
</div>
</form> <!-- FORM END -->
</div>
</div>
</div>
</body>
<script src="../dist/websmslk.js"></script> <!-- Here websms plugin -->
<script>
document.getElementById("btn_json").addEventListener("click",function(){
var new_form= new FormData;
if( document.getElementById('mobile').value !=""){
if( document.getElementById('api_key').value !=""){
if(document.getElementById('api_token').value !=""){
/**
*/
var mobile = document.getElementById('mobile').value;
var text =document.getElementById('text').value;
var sender_id = document.getElementById('sender_id').value;
var api_key = document.getElementById('api_key').value;
var api_token = document.getElementById('api_token').value;
var msgType = document.getElementById('msgType').value;
var file = document.getElementById('file').value;
var language = document.getElementById('language').value;
var duration = document.getElementById('duration').value;
var websms = new WebSMSLK({
apikey:api_key,
apitoken:api_token,
senderName:sender_id,
msgType:msgType,
});
websms.SendSMS(mobile,text);
/**
*/
}else{
alert("Invalid API Token");
}
}else{
alert("Invalid API key");
}
}else{
alert("Invalid mobile number");
}
});
document.getElementById('msgType').addEventListener('change',function(){
if($(this).val() !="sms" && $(this).val() !="unicode"){
$("#file_sel").show();
$("#voice_duration").hide();
}else{
if($(this).val()=="voice"){
$("#voice_duration").show();
}else{
$("#voice_duration").hide();
}
$("#file_sel").hide();
}
});
</script>
</html>
Download ZIP
Default use english
WebSMSLK({
"language" : 'YOUR LANGUAGE CODE'// EN // RU
});
Send sms at planned time
WebSMSLK({
"scheduledate" : '2019/11/01 00:00:00'
});
Only work with mms/voice and whatsapp msgTypes
WebSMSLK({
"file" : 'http://fileurl.com/file.wav'
});
Send More Type Of Messege
//for sms
WebSMSLK({
"msgType" : 'sms'
});
//for mms
WebSMSLK({
"msgType" : 'mms'
});
//for voice
WebSMSLK({
"msgType" : 'voice'
});
//for whatsapp
WebSMSLK({
"msgType" : 'whatsapp'
});
//for flash
WebSMSLK({
"msgType" : 'flash'
});
//for unicode
WebSMSLK({
"msgType" : 'unicode'
});
We Support Internation SMS
Default country code is "94"
WebSMSLK({
"country_code" : '44' // 91=India
});