[Asterisk-Users] PHP/AGI Problem

Jon Farmer viperdude_uk at yahoo.co.uk
Thu May 26 03:22:22 MST 2005


Alex Barnes wrote:

>Currently after:
>
>$res = $agi->agi_getdtmf(1,10000,$term,$prompt=FALSE);
>
>You test for no DTMF and then simply return null.
>Instead you could call the other piece of code you have:
>
>$status = $agi->agi_channel_status($agi->request["agi_channel"]);
>$agi->conlog("Status code: " . $status["status"]);
>$agi->conlog("Description: " . $status["description"]);
>if($status["description"] != "Line is up") {
>	exit();
>}
>
>  
>

Alex,

You are a star! I changed that bit of code based on what you said to this

function getDTMF($term, $i) {
        global $agi;
        for($x=1;$x<$i;$x++) {
                unset($res);
                $res = $agi->agi_getdtmf(1,10000,$term,$prompt=FALSE);
                if($res[0] == "") {
                        $status = 
$agi->agi_channel_status($agi->request["agi_channel"]);
                        //$agi->conlog("Status code: " . $status["status"]);
                        //$agi->conlog("Description: " . 
$status["description"]);
                        if($status["description"] != "Line is up") {
                                exit();
                        }
                }
                $agi->conlog("Res: " . $res[0]);
                if($res[0] == "") {
                        break;
                }
                if($res[0] != "") {
                        $result1 .= $res[0];
                        //$agi->conlog("Result var: " . $result1);
                }
                $agi->conlog("Result var: " . $result1);
                $agi->conlog("Channel: " . $agi->request["agi_channel"]);
                $status = 
$agi->agi_channel_status($agi->request["agi_channel"]);
                $agi->conlog("Status code: " . $status["status"]);
                $agi->conlog("Description: " . $status["description"]);
                if($status["description"] != "Line is up") {
                        exit();
                }
        }
        return $result1;
}


Now the script loops forever while the user is connected and exits if 
the user hangs up.

Thanks to everyone who helped me out, much appreciated.

Jon


	
	
		
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com



More information about the asterisk-users mailing list