Skip to content

Instantly share code, notes, and snippets.

@SendOTP
Last active January 19, 2016 10:38

Revisions

  1. SendOTP revised this gist Jan 19, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions SendOTP.php
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,15 @@ class SendOTP {
    public function generateOTP($request) {
    $data = array("countryCode" => $request['countryCode'], "mobileNumber" => $request['mobileNumber']);
    $data_string = json_encode($data);
    $ch = curl_init($this->baseUrl+'/generateOTP');
    $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);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string),
    'application-Key : Your-application-key'
    'application-Key: Your-application-key'
    ));
    $result = curl_exec($ch);
    curl_close($ch);
    @@ -26,15 +26,15 @@ public function verifyOTP($request) {
    "oneTimePassword" => $request['otp']
    );
    $data_string = json_encode($data);
    $ch = curl_init($this->baseUrl+'/verifyOTP');
    $ch = curl_init($this->baseUrl.'/verifyOTP');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string),
    'application-Key : Your-application-key'
    'application-Key: Your-application-key'
    ));
    $result = curl_exec($ch);
    curl_close($ch);
  2. SendOTP revised this gist Jan 13, 2016. 1 changed file with 0 additions and 14 deletions.
    14 changes: 0 additions & 14 deletions SendOTP.php
    Original file line number Diff line number Diff line change
    @@ -40,19 +40,5 @@ public function verifyOTP($request) {
    curl_close($ch);
    return $result;
    }

    public function checkNumberStatus($request) {
    $ch = curl_init($this->baseUrl+'/checkNumberStatus?refreshToken='+$request['countryCode']);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'AuthKey : Your-authentication-key'
    ));
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
    }
    }
    ?>
  3. SendOTP created this gist Jan 13, 2016.
    58 changes: 58 additions & 0 deletions SendOTP.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    <?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);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string),
    'application-Key : Your-application-key'
    ));
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
    }

    public function verifyOTP($request) {
    $data = array(
    "countryCode" => $request['countryCode'],
    "mobileNumber" => $request['mobileNumber'],
    "oneTimePassword" => $request['otp']
    );
    $data_string = json_encode($data);
    $ch = curl_init($this->baseUrl+'/verifyOTP');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string),
    'application-Key : Your-application-key'
    ));
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
    }

    public function checkNumberStatus($request) {
    $ch = curl_init($this->baseUrl+'/checkNumberStatus?refreshToken='+$request['countryCode']);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'AuthKey : Your-authentication-key'
    ));
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
    }
    }
    ?>