[AsteriskBrasil] AGI

Ma marcio em marcio.com.br
Quarta Março 14 13:05:21 BRT 2007


Pessoal,
 
Existe alguma forma de resgatar o que foi digitado na URA, e jogar em
uma variavel em PHP (Agi)???
Alguem conhece algum exemplo de sintaxe ou algo do tipo?
 
Eu tenho uma rota, e dentro dela, ao digitar 5 eu chamo o phpagi.
Dentro do script eu executo um SOM, STREAM FILE menu, e apos isso, eu
queria receber o que a pessoa digitou, jogando em uma variavel em php.
 
Colo abaixo o script.
#!/usr/bin/php -q
<?
//--------------
//usar um depurador mais detalhando
ob_implicit_flush(true);
set_time_limit(6);
$in=fopen("php://stdin","r");
$stdlog=fopen("/var/lib/asterisk/agi-bin/log/meu_agi.log","w");
 
$num = 37;
$dig = 123;
$som = "z6-digite";
$debug = false;
//definir a funcao antes de iniciar o ciclo principal
function read(){
    global $in, $debug, $stdlog;
    $input = str_replace("\n","",fgets($in,4096));
    if ($debug) fputs($stdlog,"read: $input\n");
        return $input;
}
 
function errlog($line){
    global $err;
    echo "VERBOSE \"$line\"\n";
}
 
function write($line){
    global $debug, $stdlog;
    if ($debug) fputs($stdlog,"write: $line\n");
        echo $line."\n";
}
 
while ($env=read()){
    $s = split(": ",$env);
    $agi[str_replace("agi_","",$s[(0)])] = trim($s[1]);
    if (($env == "") || ($env == "\n")){
        break;
    }
}
 
//main program
echo "VERBOSE \"Aqui vamos nos!\" \n";
read();
errlog("Call from ".$agi['channel']." - Chamando o telefone.");
read();
write("STREAM FILE $som X");
read();
write("SAY DIGITS $s X");
read();
//write("SAY DIGITS $dig X");
//read();
//write("SAY NUMBER $num X");
//read();
 
fclose($in);
fclose($stdlog);
 
exit;
?>
 
 
Abraco
Marcio
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: http://listas.asteriskbrasil.org/pipermail/asteriskbrasil/attachments/20070314/c2bf49f7/attachment.html


Mais detalhes sobre a lista de discussão AsteriskBrasil