today I am again in need of assistance regarding my problem. I have this code which sends sms through asterisk using the CLI command. Forgive me if you were to find some error in my code. I just started learning php 2 days ago. I need help as to how can I get the status of the SMS that I sent to a receiver. I'm actually using the phpagi library that I found in sourceforge website.
The Code:
$num = $_POST['phonenumber'];
$num2 = $_POST['phonenumber2'];
$num3 = explode(',', $num);
$msg = 'This is a system generated message: '.$_POST['message'].' || For additional information kindly reply here: '.$num2;
$type='gsm';
$method='send';
$sync='sync sms';
$span='4';
$message=$msg;
$timeout='20';
//$id='1234';
for($var = 0; $var < count($num3); $var++)
{
$destination=$num3[$var];
$chunks=wordwrap($message, 155,'\\');
$final=explode('\\', $chunks);
foreach ($final as $key => $total) {
//echo "Key: $key; Value: \"$total\"";
$total= '"'.$total.'"';
$agi->Command("$type $method $sync $span $destination $total $timeout");
}
}
Accessing asterisk using SSH putty:
How can I get this status "Successfully" using PHP and display it on the PHP page. Thanks in advance
I see you are gooing ask every odd step you do on this site, right?
For sms send you will not get any response.
You can patch asterisk to fire event on that or create custom script which will parse log.
Relative simple option is create call to Local channel and use dialplan command sendSMS, after that analyze variables it set (check in asterisk "core show application like SMS")