Guest User

Untitled

a guest
Feb 1st, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. class Sms_model extends CI_Model {
  2.  
  3. public function __construct() {
  4. parent::__construct();
  5. }
  6.  
  7. //COMMON FUNCTION FOR SENDING SMS
  8. function send_sms($message = '' , $reciever_phone = '')
  9. {
  10. $active_sms_service = $this->db->get_where('settings' , array(
  11. 'type' => 'active_sms_service'
  12. ))->row()->description;
  13. if ($active_sms_service == '' || $active_sms_service == 'disabled')
  14. return;
  15.  
  16. if ($active_sms_service == 'clickatell') {
  17. $this->send_sms_via_clickatell($message , $reciever_phone );
  18. }
  19.  
  20. }
  21.  
  22. // SEND SMS VIA CLICKATELL API
  23. function send_sms_via_clickatell($message = '' , $reciever_phone = '') {
  24.  
  25. $clickatell_user = $this->db->get_where('settings', array('type' => 'clickatell_user'))->row()->description;
  26. $clickatell_password = $this->db->get_where('settings', array('type' => 'clickatell_password'))->row()->description;
  27. $clickatell_api_id = $this->db->get_where('settings', array('type' => 'clickatell_api_id'))->row()->description;
  28. $clickatell_baseurl = "http://api.clickatell.com";
  29.  
  30. $text = urlencode($message);
  31. $to = $reciever_phone;
  32.  
  33. // auth call
  34. $url = "$clickatell_baseurl/http/auth?user=$clickatell_user&password=$clickatell_password&api_id=$clickatell_api_id";
  35.  
  36. // do auth call
  37. $ret = file($url);
  38.  
  39. // explode our response. return string is on first line of the data returned
  40. $sess = explode(":",$ret[0]);
  41. print_r($sess);echo '<br>';
  42. if ($sess[0] == "OK") {
  43.  
  44. $sess_id = trim($sess[1]); // remove any whitespace
  45. $url = "$clickatell_baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
  46.  
  47. // do sendmsg call
  48. $ret = file($url);
  49. $send = explode(":",$ret[0]);
  50. print_r($send);echo '<br>';
  51. if ($send[0] == "ID") {
  52. echo "successnmessage ID: ". $send[1];
  53. } else {
  54. echo "send message failed";
  55. }
  56. } else {
  57. echo "Authentication failure: ". $ret[0];
  58. }
  59. }
  60.  
  61.  
  62. // SEND SMS VIA TWILIO API
  63.  
  64.  
  65. //SMS via msg91
  66.  
  67. }
  68.  
  69. class Sms_model extends CI_Model {
  70.  
  71. public function __construct() {
  72. parent::__construct();
  73. }
  74.  
  75. //COMMON FUNCTION FOR SENDING SMS
  76. function send_sms($message = '' , $reciever_phone = '')
  77. {
  78. $active_sms_service = $this->db->get_where('settings' , array(
  79. 'type' => 'active_sms_service'
  80. ))->row()->description;
  81. if ($active_sms_service == '' || $active_sms_service == 'disabled')
  82. return;
  83.  
  84. if ($active_sms_service == 'clickatell') {
  85. $this->send_sms_via_clickatell($message , $reciever_phone );
  86. }
  87.  
  88. }
  89.  
  90. // SEND SMS VIA CLICKATELL API
  91. function send_sms_via_clickatell($message = '' , $reciever_phone = '') {
  92.  
  93. $clickatell_user = $this->db->get_where('settings', array('type' => 'clickatell_user'))->row()->description;
  94. $clickatell_password = $this->db->get_where('settings', array('type' => 'clickatell_password'))->row()->description;
  95. //$clickatell_api_id = $this->db->get_where('settings', array('type' => 'clickatell_api_id'))->row()->description;
  96. $clickatell_baseurl = "http://api.bizsms.pk";
  97.  
  98. $text = urlencode($message);
  99. $to = $reciever_phone;
  100.  
  101. // auth call
  102. $url = "$clickatell_baseurl/api-send-branded-sms.aspx?username=$clickatell_user&pass=$clickatell_password";
  103.  
  104. // do auth call
  105. $ret = file($url);
  106.  
  107. // explode our response. return string is on first line of the data returned
  108. $sess = explode(":",$ret[0]);
  109. print_r($sess);echo '<br>';
  110. if ($sess[0] == "OK") {
  111.  
  112. $sess_id = trim($sess[1]); // remove any whitespace
  113. $url = "$clickatell_baseurl/api-send-branded-sms.aspx?username=$clickatell_user&pass=$clickatell_password&text=$text&masking=Rising%20star&destinationnum=$to&language=English";
  114.  
  115. // do sendmsg call
  116. $ret = file($url);
  117. $send = explode(":",$ret[0]);
  118. print_r($send);echo '<br>';
  119. if ($send[0] == "ID") {
  120. echo "successnmessage ID: ". $send[1];
  121. } else {
  122. echo "send message failed";
  123. }
  124. } else {
  125. echo "Authentication failure: ". $ret[0];
  126. }
  127. }
  128.  
  129.  
  130. // SEND SMS VIA TWILIO API
  131.  
  132.  
  133. //SMS via msg91
  134.  
  135. }
Add Comment
Please, Sign In to add comment