In CodeIgniter It is very easy to integrate SMS facility to your application. Since SMS gateway follows different methods, here are some steps to get an idea that how you can do it.
Controller:
1. Create Controller
2. Now you can create a function let’s say sendSms() . In that function you can apply the following code. Here to test you can sent the static values to check whether functions are working or not. The commented part is the dynamic values.
3. Write the below code to send message.
$this->load->model (‘modelname’, “sms”);
$message=’ I am xyz’;
$mobile=9999999999;
// If Mobile No and Message are Dynamic so write below the line.
//$message=$this->input->post(‘Message’);
// $mobile = $this->input->post(‘mobileno’);
$this->sms->smssend($mobile,$message);
Model:
1. Create Model.
<?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);
class modelname extends CI_Model {
public function smssend($mobile,$message)
{
$request=’username=username &pass=123456&senderid=Usersenderid &dest_mobileno=’.$mobile.’&message=’.$message.’&response=Y’;
$ch = curl_init(‘www.smsjust.com/blank/sms/user/urlsms.php’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$resuponce=curl_exec($ch);
curl_close($ch);
return $resuponce;
}
}