Quick Start

Last updated: May 29th, 2020

Download

Download our jquery api helper
Current version 1.0

Download newsletters.class master Download JavaScript Without jQuery Version

Installation

Step One

Download and any version of jquery api helper and include your jquery script.

Default code example:

<script src="websmslk.js"> </script>

Step Two

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

    

Get Your Own Sender Id

For get your own Sender Id call our support center +94-777-004416 or mail to support@newsletters.lk

Send Message

Send Messege Sample

     websms.SendSMS("0777004416","hello my first web sms");
                                        

Full sample

Send Messege Sample

<!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 - jQuery 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://app.newsletters.lk/apis
                </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/websms.lk.min.js"></script> <!-- Here websms plugin -->
<script>

    $(document).on("click touch","#btn_json",function(){
        var new_form= new FormData;
        if($("#mobile").val() !=""){
            if($("#api_key").val() !=""){
                if($("#api_token").val() !=""){
                    /**
                        */
                        var mobile = $("#mobile").val();
                        var text = $("#text").val();
                        var sender_id = $("#sender_id").val();
                        var api_key = $("#api_key").val();
                        var api_token = $("#api_token").val();
                        var msgType = $("#msgType").val();
                        var file = $("#file").val();
                        var language = $("#language").val();
                        var duration = $("#duration").val();

                        var websms=$.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).on("change","#msgType",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 newsletters.class master

Other Options

Language

Default use english


    $.WebSMSLK({
        "language" : 'YOUR LANGUAGE CODE'// EN // RU
    });
                                        
Schedule your sms

Send sms at planned time


    $.WebSMSLK({
        "scheduledate" : '2019/11/01 00:00:00'
    });
                                        
Send File Using MMS or Whatsapp

Only work with mms/voice and whatsapp msgTypes


    $.WebSMSLK({
        "file" : 'http://fileurl.com/file.wav'
    });
                                            
Messege Types

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' 
        });

                                                
Default country

We Support Internation SMS
Default country code is "94"


            $.WebSMSLK({
                "country_code" : '44' // 91=India 
            });