D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
www
/
cas
/
application
/
libraries
/
util
/
Filename :
SMSSender.php
back
Copy
<?php /* * ************************************************* * File Name: SMSSender.php * * File Description: Utility Class For Sending SMS. * * Author: Softpro India Pvt. Ltd. * * Date Created: 29/04/2018 * * Date Last Modified: 04/02/2020 * /************************************************** */ class SMSSender { const BASE_URL = ''; const USER_NAME = ''; const PASSWORD = ''; const SENDER_ID = ''; const RESPONSE = 'Y'; const FINAL_URL_PRE = self::BASE_URL . 'username=' . self::USER_NAME . '&pass=' . self::PASSWORD . '&senderid=' . self::SENDER_ID . '&message='; const FINAL_URL_POST = '&response=' . self::RESPONSE; public function sendSMS($mobile, $message) { $ch = curl_init(); $url = self::FINAL_URL_PRE . urlencode($message) . "&dest_mobileno=" . $mobile . self::FINAL_URL_POST; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $deliveryResponse = curl_exec($ch); $response = explode("-", $deliveryResponse)[0]; curl_close($ch); $error_code = ($response != '0') ? "000" : "-1"; $deliveryStatus = ($error_code == '000' || $error_code == 000) ? "T" : "F"; self::logThisSMSTransaction($deliveryStatus, $mobile, $message, self::SENDER_ID); } public static function logThisSMSTransaction($deliveryStatus, $mobile, $message, $senderId) { $CI = & get_instance(); $form_data = array( 'sms_number' => $mobile, 'sms_content' => $message, 'sms_sender_id' => $senderId, 'sms_delivery_status' => $deliveryStatus, 'sms_date' => date("Y-m-d H:i:s") ); $CI->load->database(); $CI->db->insert('sent_sms_log', $form_data); } }