Skip to content

Instantly share code, notes, and snippets.

@SendOTP
Last active January 19, 2016 10:38
Show Gist options
  • Save SendOTP/6e8b948e09b58a08a597 to your computer and use it in GitHub Desktop.
Save SendOTP/6e8b948e09b58a08a597 to your computer and use it in GitHub Desktop.
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);
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;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment