Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Sms_model extends CI_Model {
- public function __construct() {
- parent::__construct();
- }
- //COMMON FUNCTION FOR SENDING SMS
- function send_sms($message = '' , $reciever_phone = '')
- {
- $active_sms_service = $this->db->get_where('settings' , array(
- 'type' => 'active_sms_service'
- ))->row()->description;
- if ($active_sms_service == '' || $active_sms_service == 'disabled')
- return;
- if ($active_sms_service == 'clickatell') {
- $this->send_sms_via_clickatell($message , $reciever_phone );
- }
- }
- // SEND SMS VIA CLICKATELL API
- function send_sms_via_clickatell($message = '' , $reciever_phone = '') {
- $clickatell_user = $this->db->get_where('settings', array('type' => 'clickatell_user'))->row()->description;
- $clickatell_password = $this->db->get_where('settings', array('type' => 'clickatell_password'))->row()->description;
- $clickatell_api_id = $this->db->get_where('settings', array('type' => 'clickatell_api_id'))->row()->description;
- $clickatell_baseurl = "http://api.clickatell.com";
- $text = urlencode($message);
- $to = $reciever_phone;
- // auth call
- $url = "$clickatell_baseurl/http/auth?user=$clickatell_user&password=$clickatell_password&api_id=$clickatell_api_id";
- // do auth call
- $ret = file($url);
- // explode our response. return string is on first line of the data returned
- $sess = explode(":",$ret[0]);
- print_r($sess);echo '<br>';
- if ($sess[0] == "OK") {
- $sess_id = trim($sess[1]); // remove any whitespace
- $url = "$clickatell_baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
- // do sendmsg call
- $ret = file($url);
- $send = explode(":",$ret[0]);
- print_r($send);echo '<br>';
- if ($send[0] == "ID") {
- echo "successnmessage ID: ". $send[1];
- } else {
- echo "send message failed";
- }
- } else {
- echo "Authentication failure: ". $ret[0];
- }
- }
- // SEND SMS VIA TWILIO API
- //SMS via msg91
- }
- class Sms_model extends CI_Model {
- public function __construct() {
- parent::__construct();
- }
- //COMMON FUNCTION FOR SENDING SMS
- function send_sms($message = '' , $reciever_phone = '')
- {
- $active_sms_service = $this->db->get_where('settings' , array(
- 'type' => 'active_sms_service'
- ))->row()->description;
- if ($active_sms_service == '' || $active_sms_service == 'disabled')
- return;
- if ($active_sms_service == 'clickatell') {
- $this->send_sms_via_clickatell($message , $reciever_phone );
- }
- }
- // SEND SMS VIA CLICKATELL API
- function send_sms_via_clickatell($message = '' , $reciever_phone = '') {
- $clickatell_user = $this->db->get_where('settings', array('type' => 'clickatell_user'))->row()->description;
- $clickatell_password = $this->db->get_where('settings', array('type' => 'clickatell_password'))->row()->description;
- //$clickatell_api_id = $this->db->get_where('settings', array('type' => 'clickatell_api_id'))->row()->description;
- $clickatell_baseurl = "http://api.bizsms.pk";
- $text = urlencode($message);
- $to = $reciever_phone;
- // auth call
- $url = "$clickatell_baseurl/api-send-branded-sms.aspx?username=$clickatell_user&pass=$clickatell_password";
- // do auth call
- $ret = file($url);
- // explode our response. return string is on first line of the data returned
- $sess = explode(":",$ret[0]);
- print_r($sess);echo '<br>';
- if ($sess[0] == "OK") {
- $sess_id = trim($sess[1]); // remove any whitespace
- $url = "$clickatell_baseurl/api-send-branded-sms.aspx?username=$clickatell_user&pass=$clickatell_password&text=$text&masking=Rising%20star&destinationnum=$to&language=English";
- // do sendmsg call
- $ret = file($url);
- $send = explode(":",$ret[0]);
- print_r($send);echo '<br>';
- if ($send[0] == "ID") {
- echo "successnmessage ID: ". $send[1];
- } else {
- echo "send message failed";
- }
- } else {
- echo "Authentication failure: ". $ret[0];
- }
- }
- // SEND SMS VIA TWILIO API
- //SMS via msg91
- }
Add Comment
Please, Sign In to add comment