File: /var/www/html/nt/application/helpers/otp_helper_wbhb.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function sendsms($otp,$phoneno){
$data = array();
$ch = curl_init();
$baseurl = 'http://dndopen.jhaveritechno.com/api/v4/?api_key='.API_KEY_FOR_SMS;
$validTime = '2%20minutes';
//echo $otp; die;
//$message = "Your%20OTP%20for%20login%20to%20Asset%20Management%20System%20is%20".$otp.".%20This%20OTP%20is%20valid%20for%2060%20seconds.%20Please%20do%20not%20share%20this%20OTP%20with%20others.SYSCNT";
//$message = "OTP%20for%20Login%20Transaction%20on%20SYSCENTRIC%20is%20".$otp.".%20Do%20not%20share%20this%20OTP%20to%20anyone%20for%20security%20reasons.";
$message = "Your%20OTP%20for%20login%20in%20the%20portal%20of%20WBHB%20is%20".$otp.".%20This%20OTP%20is%20valid%20for%20".$validTime.".%20Please%20don't%20share%20the%20OTP%20with%20others.";
$url = $baseurl.'&method=sms&message='.$message.'&to='.$phoneno.'&sender='.SENDER_FOR_SMS.'&entity_id='.ENTITY_ID_FOR_SMS.'&template_id=1207168733351404954';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$error = 'Error:' . curl_error($ch);
}
curl_close($ch);
$data['error'] = $error;
$data['response'] = json_decode($result);
//echo "<pre>"; print_r($data);
//print_r(curl_getinfo($ch)); die;
//echo $error; die;
return $data;
}
function sendsignupsms($otp,$phoneno){
$data = array();
$ch = curl_init();
$baseurl = 'http://dndopen.jhaveritechno.com/api/v4/?api_key='.API_KEY_FOR_SMS;
//echo $otp; die;
$message = "Your%20OTP%20for%20signing%20up%20in%20the%20portal%20of%20WBHB%20is%20".$otp.".%20Please%20don't%20share%20the%20OTP%20with%20others.";
$url = $baseurl.'&method=sms&message='.$message.'&to='.$phoneno.'&sender='.SENDER_FOR_SMS.'&entity_id='.ENTITY_ID_FOR_SMS.'&template_id=1207168733299237293';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$error = 'Error:' . curl_error($ch);
}
curl_close($ch);
$data['error'] = $error;
$data['response'] = json_decode($result);
//echo "<pre>"; print_r($data);
//print_r(curl_getinfo($ch)); die;
//echo $error; die;
return $data;
}
function generateotp($phone, $type){
$data = array();
$otp = random_int(100000, 999999);
if($type == 'mobile_verify') {
$data= sendsignupsms($otp,$phone);
}
else {
$data= sendsms($otp,$phone);
}
$data['otp'] = $otp;
return $data;
}
?>