简体   繁体   中英

Passing PHP value to AGI

I'm still new to PHP and asterisk. I am trying to pass the value from an HTML text input to a php page which communicates with asterisk to send an sms text via GSM Modem. So far this is the code that I have experimented on.

     $num = $_POST['cNum'];
     $msg = $_POST['cMessage'];
     $type='gsm';
     $method='send';
     $sync='sync sms';
     $span='4';
     $destination=$num;
     $message=$msg;
     $timeout='20';
     $id='1234';
     $agi->Command("$type $method $sync $span $destination $message $timeout $id");
     exit(0);

This does work but the problem is for example I were to enter "Sample Space" to the text input "cMessage", the text message that I will receive will only be "Sample" (without the double quotation marks). All words after the first space character is omitted. However if I were to try and code it this way:

     $num = $_POST['cNum'];
     $msg = $_POST['cMessage'];
     $type='gsm';
     $method='send';
     $sync='sync sms';
     $span='4';
     $destination=$num;
     $message='"Sample Space"';   <----------- for example
     $timeout='20';
     $id='1234';
     $agi->Command("$type $method $sync $span $destination $message $timeout $id");
     exit(0);

I could receive the whole message "Sample Space" (without the double quotation marks) Could someone please help me with this?

Seams like you missed quotation when learned php.

Try use it

$message='\"Sample Space\"';   <----------- for example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM