Skip to content

Instantly share code, notes, and snippets.

@SendOTP
SendOTP / index.html
Last active March 30, 2021 19:22
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',
@SendOTP
SendOTP / generateOTP.java
Last active January 12, 2018 13:04
Sample code for server-side get OTP
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import org.json.JSONObject;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
/*
@SendOTP
SendOTP / sendotp.php
Last active March 30, 2021 19:22
Sample codes for server-side Get OTP in Response
<?php
session_start();
class SendOTP {
private $baseUrl = "https://sendotp.msg91.com/api";
public function callGenerateAPI($request) {
$data = array("countryCode" => $request['countryCode'], "mobileNumber" => $request['mobileNumber'],"getGeneratedOTP" => true);
$data_string = json_encode($data);
$ch = curl_init($this->baseUrl.'/generateOTP');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
@SendOTP
SendOTP / SendOTPBasic.php
Last active February 1, 2016 08:44
SendOTP : Check mobile number status : PHP sample code to verify request on server side in basic architecture
<?php
class SendOTPBasic {
private $baseUrl = "http://sendotp.msg91.com/api";
public function checkNumberStatus($request) {
$ch = curl_init($this->baseUrl+'/checkNumberStatus?refreshToken={REFRESH TOKEN}&countryCode={91}&mobileNumber={98XXXXX}');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
@SendOTP
SendOTP / SendOTPBasic.java
Last active July 10, 2018 07:45
SendOTP : Java sample code to verify request on server side in basic architecture
/*
* This code is based on jersey-client library.
* For gradle based project use compile 'com.sun.jersey:jersey-client:1.18.4'
* You can also download the jar and add it to you project.
* */
public class SendOTPBasic {
//Base URL
public static String baseUrl = "http://sendotp.msg91.com/api";
// Your application key
@SendOTP
SendOTP / SendOTP.java
Last active January 21, 2016 07:27
SendOTP : Java server side sample code for Custom Security Architecture.
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import org.json.JSONObject;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
/*
@SendOTP
SendOTP / SendOTP.php
Last active January 19, 2016 10:38
SendOTP : PHP Sever Side Sample Code for Custom Security Architecture
<?php
class SendOTP {
private $baseUrl = "http://sendotp.msg91.com/api";
public function generateOTP($request) {
$data = array("countryCode" => $request['countryCode'], "mobileNumber" => $request['mobileNumber']);
$data_string = json_encode($data);
$ch = curl_init($this->baseUrl.'/generateOTP');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@SendOTP
SendOTP / Index.php
Last active May 10, 2016 11:50
SendOTP Client Side sample code JavaScript
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script type="text/javascript">
function sendOTP() {
var data = {"countryCode": "country code", "mobileNumber": "Mobile number to be verified"};
$.ajax({
url: 'http://Your-domain-name/path/sendotp.php?action=generateOTP',
type: 'POST',
dataType: 'json',
data: data,