How to use any api for sms integration.
PLZ anybody can help…
How to use any api for sms integration.
PLZ anybody can help…
I’ve never worked with SMS, but I leave 2 links that may be useful:
Discussion
Extensions
I hope it helps.
create a simple txt file named smsapi.txt which contain SMS link API.
create one component class so that you can use that in whole application.
<?php
class SmsApi {
public $r;
public function init()
{
parent::init();
}
public function sendsms($to,$message)
{
$filename = dirname(__FILE__).'/smsapi.txt';
$fh = fopen($filename, 'r') or die("Can't open file.");
$msg_api = fread($fh,filesize($filename));
$update_num = str_replace('MOBILE_NO', $to ,$msg_api);
$update_msg=urlencode($message);
$update_msg = str_replace('MESSAGE_CONTENT', $update_msg ,$update_num);
fclose($fh);
$update_msg = trim($update_msg);
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $update_msg);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($c, CURLOPT_RETURNTRANSFER,true);
$this->r=curl_exec($c);
return $this->r;
}
}
now call the function using following code from controller.
$smsobj=new SmsApi;
$r=$smsobj->sendsms($output,$message);