Create a gist now

Instantly share code, notes, and snippets.

@SendOTP /index.html
Last active Aug 11, 2017

What would you like to do?
SendOTP: Client Side flow sample code
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script type="text/javascript">
function sendOTP() {
var data = JSON.stringify({countryCode: "country code", mobileNumber: "Mobile number to be verified"});
$.ajax({
url: 'https://sendotp.msg91.com/api/generateOTP',
type: 'POST',
crossDomain: true,
processData: false,
contentType: 'application/json',
headers: {'Access-Control-Allow-Origin': '*'},
beforeSend: function (request)
{
request.setRequestHeader("Package-Name", "Your domain name.");
request.setRequestHeader("Secret-Key", "Your 8 character password.");
},
dataType: 'json',
data: data,
success: function(data){
var resp = JSON.parse(response)
console.log(resp.status);
},
error: function(jqXHR, textStatus, ex) {
console.log(textStatus + "," + ex + "," + jqXHR.responseText);
}
});
}
function verifyOTP() {
var data = JSON.stringify({countryCode: "country code", mobileNumber: "Mobile number to be verified",oneTimePassword:"One time password"});
$.ajax({
url: 'https://sendotp.msg91.com/api/verifyOTP',
type: 'POST',
crossDomain: true,
processData: false,
contentType: 'application/json',
headers: {'Access-Control-Allow-Origin': '*'},
beforeSend: function (request)
{
request.setRequestHeader("Package-Name", "Your domain name.");
request.setRequestHeader("Secret-Key", "Your 8 character password.");
},
dataType: 'json',
data: data,
success: function(data){
var resp = JSON.parse(response)
console.log(resp.status);
},
error: function(jqXHR, textStatus, ex) {
console.log(textStatus + "," + ex + "," + jqXHR.responseText);
}
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment