File: /var/www/html/nt/application/helpers/otp_helper.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=Acbb9b01166125066737f7170c4f573d3';
//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.";
$url = $baseurl.'&method=sms&message='.$message.'&to='.$phoneno.'&sender=SYSCNT&entity_id=1301163999688234159&template_id=1507167447605971218';
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){
$data = array();
$otp = random_int(100000, 999999);
$data= sendsms($otp,$phone);
$data['otp'] = $otp;
return $data;
}*/
function generateotp($phone, $type)
{
$data = array();
$otp = random_int(100000, 999999);
$data= sendsms($otp, $phone, $type);
$data['otp'] = $otp;
return $data;
}
function sendsms($otp, $phoneno, $type)
{
$data = array();
$ch = curl_init();
$baseurl = 'http://dndopen.jhaveritechno.com/api/v4/?api_key='.API_KEY_FOR_SMS;
$valid_time = '300%20Seconds';
$message = '';
switch ($type) {
case 'mobile_verify':
$message = "Your%20OTP%20for%20signing%20up%20in%20the%20portal%20of%20WBHB%20is%20".$otp.".%20Please%20don't%20share%20the%20OTP%20with%20others.%20WBHB.";
$template_id = "1207170305977742182";
break;
case 'login_email_verify':
$message = "Your%20OTP%20for%20login%20in%20the%20portal%20of%20WBHB%20is%20".$otp.".%20This%20OTP%20is%20valid%20for%20".$valid_time.".%20Please%20don't%20share%20the%20OTP%20with%20others.WBHB";
$template_id = "1207170254149551827";
break;
}
$url = $baseurl.'&method=sms&message='.$message.'&to='.$phoneno.'&sender='.SENDER_FOR_SMS.'&entity_id='.ENTITY_ID_FOR_SMS.'&template_id='.$template_id.'';
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;
}
?>