[AsteriskBrasil] RES: script phpagi portabilidade
Eder
eder.asterisk em yahoo.com.br
Quarta Novembro 21 17:15:05 BRST 2012
Danilo,
As configurações estão iguais as que você passou, pois estou apenas
testando o funcionamento, segue a baixo meus arquivos e a mensagem completa.
Extensions .conf
exten => _0XX[6-9]XXXXXXX,1,NoOp(---> DE ${CALLERID(num)} PARA ${EXTEN} <--)
exten => _0XX[6-9]XXXXXXX,n,AGI(portabilidade.php,${EXTEN:1})
exten => _0XX[6-9]XXXXXXX,n,NoOp(---> A OPERADORA DISCADA E:
${OPERADORA} <---)
exten => _0XX[6-9]XXXXXXX,n,Hangup()
portabilidade.php
#!/usr/bin/php -q
<?php
include("phpagi.php");
//version: Danilo Almeida
//package: AGI Portabilidade PHP
//copyright: Copyright (C) Open Source.
//license: GNU/GPL, see LICENSE.php
//Agi para consulta de operadora para celulares portados
//Acesso ao banco de dados fornecido por http://magnussolution.com
//Contato: danilo.almeida em g1telecom.com.br
<mailto:danilo.almeida em g1telecom.com.br>
$agi = new AGI(); //instanciando objeto
$numero = $argv[1]; //pegando numero discado no extensions.conf
$numero = "55".$numero; //acrescentando 55 para enviar formato E164
$url="http://magnussolution.com/portabilidade.php?seache_number=$numero"
<http://magnussolution.com/portabilidade.php?seache_number=$numero>;
$chave = file_get_contents($url);
//$array_resposta = explode('#', $texto_resposta);
switch($chave){
case 5312 :
$operadora = 'CTBC CELULAR S.A' ;
break;
case 55314 :
$operadora = 'BRASIL TELECOM CELULAR' ;
break;
case 55320 :
$operadora = 'VIVO' ;
break;
case 55321 :
$operadora = 'AMERICEL' ;
break;
case 55323 :
$operadora = 'TELEMIG CELULAR' ;
break;
case 55324 :
$operadora = 'AMAZONIA CELULAR' ;
break;
case 55331 :
$operadora = 'TNL PCS' ;
break;
case 55337 :
$operadora = 'UNICEL DO BRASIL' ;
break;
case 55341 :
$operadora = 'TIM CELULAR' ;
break;
case 55343 :
$operadora = 'SERCOMTEL CELULAR' ;
break;
case 55349 :
$operadora = 'OPTIONS COMP' ;
break;
case 55377 :
$operadora = 'MCS (Nextel)' ;
break;
case 55390 :
$operadora = 'TELCOM TELECOMUNICACOES DO BRASIL' ;
break;
case 55391 :
$operadora = 'FALKLAND TECNOLOGIA' ;
break;
case 55392 :
$operadora = 'IRIDIUM' ;
break;
case 55393 :
$operadora = 'GLOBALSTAR DO BRASIL' ;
break;
}
$agi->set_variable("OPERADORA", $operadora);
exit();
?>
*Mensagem completa de erro.*
-- Executing [011999878880 em teste4:1] NoOp("SIP/1002-00000001", "---> DE
1002 PARA 011999878880 <--") in new stack
-- Executing [011999878880 em teste4:2] AGI("SIP/1002-00000001",
"portabilidade.php,11999878880") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/portabilidade.php
<SIP/1002-00000001>AGI Tx >> agi_request: portabilidade.php
<SIP/1002-00000001>AGI Tx >> agi_channel: SIP/1002-00000001
<SIP/1002-00000001>AGI Tx >> agi_language: pt_BR
<SIP/1002-00000001>AGI Tx >> agi_type: SIP
<SIP/1002-00000001>AGI Tx >> agi_uniqueid: 1353525272.1
<SIP/1002-00000001>AGI Tx >> agi_version: 1.8.11.0
<SIP/1002-00000001>AGI Tx >> agi_callerid: 1002
<SIP/1002-00000001>AGI Tx >> agi_calleridname: device
<SIP/1002-00000001>AGI Tx >> agi_callingpres: 0
<SIP/1002-00000001>AGI Tx >> agi_callingani2: 0
<SIP/1002-00000001>AGI Tx >> agi_callington: 0
<SIP/1002-00000001>AGI Tx >> agi_callingtns: 0
<SIP/1002-00000001>AGI Tx >> agi_dnid: 011999878880
<SIP/1002-00000001>AGI Tx >> agi_rdnis: unknown
<SIP/1002-00000001>AGI Tx >> agi_context: teste4
<SIP/1002-00000001>AGI Tx >> agi_extension: 011999878880
<SIP/1002-00000001>AGI Tx >> agi_priority: 2
<SIP/1002-00000001>AGI Tx >> agi_enhanced: 0.0
<SIP/1002-00000001>AGI Tx >> agi_accountcode:
<SIP/1002-00000001>AGI Tx >> agi_threadid: 107338640
<SIP/1002-00000001>AGI Tx >> agi_arg_1: 11999878880
<SIP/1002-00000001>AGI Tx >>
<SIP/1002-00000001>AGI Rx << Usage: php [options] [-f] <file> [--] [args...]
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/1002-00000001>AGI Rx << php [options] -r <code> [--] [args...]
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << php [options] [-B <begin_code>] -R
<code> [-E <end_code>] [--] [args...]
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << php [options] [-B <begin_code>] -F
<file> [-E <end_code>] [--] [args...]
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << php [options] -- [args...]
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << php [options] -a
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx <<
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -a Run interactively
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -c <path>|<file> Look for php.ini file in
this directory
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -n No php.ini file will be used
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -d foo[=bar] Define INI entry foo
with value 'bar'
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -e Generate extended information for
debugger/profiler
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -f <file> Parse <file>.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -h This help
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -i PHP information
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -l Syntax check only (lint)
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -m Show compiled in modules
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -r <code> Run PHP <code> without using
script tags <?..?>
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -B <begin_code> Run PHP <begin_code>
before processing input lines
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -R <code> Run PHP <code> for every input line
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -F <file> Parse and execute <file> for
every input line
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -E <end_code> Run PHP <end_code> after
processing all input lines
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -H Hide any passed
arguments from external tools.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -s Display colour syntax highlighted source.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -v Version number
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -w Display source with stripped comments
and whitespace.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << -z <file> Load Zend extension <file>.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx <<
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << args... Arguments passed to script. Use
-- args when first argument
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << starts with - or script
is read from stdin
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx <<
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << --rf <name> Show information about
function <name>.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << --rc <name> Show information about class
<name>.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx << --re <name> Show information about
extension <name>.
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
<SIP/1002-00000001>AGI Rx <<
<SIP/1002-00000001>AGI Tx >> 510 Invalid or unknown command
[2012-11-21 17:14:32] ERROR[4161]: utils.c:1164 ast_carefulwrite:
write() returned error: Broken pipe
-- <SIP/1002-00000001>AGI Script portabilidade.php completed,
returning 0
-- Executing [011999878880 em teste4:3] NoOp("SIP/1002-00000001",
"---> A OPERADORA DISCADA E: <---") in new stack
-- Executing [011999878880 em teste4:4] Hangup("SIP/1002-00000001",
"") in new stack
== Spawn extension (teste4, 011999878880, 4) exited non-zero on
'SIP/1002-00000001'
Em 21/11/2012 16:58, Danilo Almeida escreveu:
>
> Posta ai como que ta seus arquivos
>
> *att*
>
> **
>
> *Danilo Ricardo de Almeida***
>
> *De:*asteriskbrasil-bounces em listas.asteriskbrasil.org
> [mailto:asteriskbrasil-bounces em listas.asteriskbrasil.org] *Em nome de
> *Eder
> *Enviada em:* Wednesday, November 21, 2012 4:16 PM
> *Para:* asteriskbrasil em listas.asteriskbrasil.org
> *Assunto:* Re: [AsteriskBrasil] script phpagi portabilidade
>
> Boa Tarde,
>
> Alguem poderia me ajudar ao executar o AGI conforme o procedimento
> a baixo, surge as mensagens.
>
>
> <SIP/1002-0000000f>AGI Rx << Usage: php [options] [-f] <file> [--]
> [args...]
> <SIP/1002-0000000f>AGI Tx >> 510 Invalid or unknown command
> <SIP/1002-0000000f>AGI Rx << php [options] -r <code> [--] [args...]
> <SIP/1002-0000000f>AGI Tx >> 510 Invalid or unknown command
> [2012-11-21 16:16:21] ERROR[11877]: utils.c:1164 ast_carefulwrite:
> write() returned error: Broken pipe
> <SIP/1002-0000000f>AGI Rx << php [options] [-B <begin_code>] -R
> <code> [-E <end_code>] [--] [args...]
>
>
>
> Em 20/08/2012 16:35, Danilo Almeida escreveu:
>
> Bom galera, depois de tanta luta com o agiphp, fiz um script bem
> simples para consultar portabilidade em php.
>
> Utilizo como servidor de consulta, o servidor Magnus solution que
> o Amigo disponibilizou para a galera da lista.
>
> Esse fiz somente para ver se daria certo. Para questão de somente
> consulta, funcionou perfeitamente.
>
> Utilizei algumas informações de alguns posts anteriores.
>
> Extensions .conf
>
> exten => _0XX[6-9]XXXXXXX,1,NoOp(---> DE ${CALLERID(num)} PARA
> ${EXTEN} <--)
>
> exten => _0XX[6-9]XXXXXXX,n,AGI(portabilidade.php,${EXTEN:1})
>
> exten => _0XX[6-9]XXXXXXX,n,NoOp(---> A OPERADORA DISCADA E:
> ${OPERADORA} <---)
>
> exten => _0XX[6-9]XXXXXXX,n,Hangup()
>
> portabilidade.php
>
> #!/usr/bin/php -q
>
> <?php
>
> include("phpagi.php");
>
> //version: Danilo Almeida
>
> //package: AGI Portabilidade PHP
>
> //copyright: Copyright (C) Open Source.
>
> //license: GNU/GPL, see LICENSE.php
>
> //Agi para consulta de operadora para celulares portados
>
> //Acesso ao banco de dados fornecido por http://magnussolution.com
>
> //Contato: danilo.almeida em g1telecom.com.br
> <mailto:danilo.almeida em g1telecom.com.br>
>
> $agi = new AGI(); //instanciando objeto
>
> $numero = $argv[1]; //pegando numero discado no extensions.conf
>
> $numero = "55".$numero; //acrescentando 55 para enviar formato E164
>
> $url="http://magnussolution.com/portabilidade.php?seache_number=$numero"
> <http://magnussolution.com/portabilidade.php?seache_number=$numero>;
>
> $chave = file_get_contents($url);
>
> //$array_resposta = explode('#', $texto_resposta);
>
> switch($chave){
>
> case 5312 :
>
> $operadora = 'CTBC CELULAR S.A' ;
>
> break;
>
> case 55314 :
>
> $operadora = 'BRASIL TELECOM CELULAR' ;
>
> break;
>
> case 55320 :
>
> $operadora = 'VIVO' ;
>
> break;
>
> case 55321 :
>
> $operadora = 'AMERICEL' ;
>
> break;
>
> case 55323 :
>
> $operadora = 'TELEMIG CELULAR' ;
>
> break;
>
> case 55324 :
>
> $operadora = 'AMAZONIA CELULAR' ;
>
> break;
>
> case 55331 :
>
> $operadora = 'TNL PCS' ;
>
> break;
>
> case 55337 :
>
> $operadora = 'UNICEL DO BRASIL' ;
>
> break;
>
> case 55341 :
>
> $operadora = 'TIM CELULAR' ;
>
> break;
>
> case 55343 :
>
> $operadora = 'SERCOMTEL CELULAR' ;
>
> break;
>
> case 55349 :
>
> $operadora = 'OPTIONS COMP' ;
>
> break;
>
> case 55377 :
>
> $operadora = 'MCS (Nextel)' ;
>
> break;
>
> case 55390 :
>
> $operadora = 'TELCOM TELECOMUNICACOES DO BRASIL' ;
>
> break;
>
> case 55391 :
>
> $operadora = 'FALKLAND TECNOLOGIA' ;
>
> break;
>
> case 55392 :
>
> $operadora = 'IRIDIUM' ;
>
> break;
>
> case 55393 :
>
> $operadora = 'GLOBALSTAR DO BRASIL' ;
>
> break;
>
> }
>
> $agi->set_variable("OPERADORA", $operadora);
>
> exit();
>
> ?>
>
> Retorno CLI
>
> -- Executing [91538563 em contexto-ramais-voip:1]
> NoOp("SIP/5001-0000011d", "---> DE 5001 PARA 91538563 <--") in new
> stack
>
> -- Executing [91538563 em contexto-ramais-voip:2]
> AGI("SIP/5001-0000011d", "portabilidade.php,4391538563") in new stack
>
> -- Launched AGI Script /var/lib/asterisk/agi-bin/portabilidade.php
>
> -- <SIP/5001-0000011d>AGI Script portabilidade.php completed,
> returning 0
>
> -- Executing [91538563 em contexto-ramais-voip:3]
> NoOp("SIP/5001-0000011d", "---> A OPERADORA DISCADA E: VIVO <---")
> in new stack
>
> *att*
>
> **
>
> *Danilo Ricardo de Almeida*
>
>
>
>
> _______________________________________________
>
> KHOMP Inovação: External Board Series
>
> Módulos de 1/2 rack e 1U para todas as interfaces e soluções Asterisk e FreeSWITCH.
>
> Tenha a External Series Experience na sua aplicação. Visitewww.khomp.com <http://www.khomp.com>
>
> _______________________________________________
>
> DIGIVOICE Fabricante de Placas de Voz e Channel Bank
>
> 20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM
>
> Centro Treinamento - Curso de PABX IP - Asterisk - Sitewww.digivoice.com.br <http://www.digivoice.com.br>
>
> ________
>
> YEALINK: Telefones IP e VídeoPhones IP com o melhor custo/benefício do mercado.
>
> email:yealink em commlogik.com.br <mailto:yealink em commlogik.com.br> |www.commlogik.com.br <http://www.commlogik.com.br> | (11) 5503-1011
>
> ______________________________________________
>
> Para remover seu email desta lista, basta enviar um email em branco paraasteriskbrasil-unsubscribe em listas.asteriskbrasil.org <mailto:asteriskbrasil-unsubscribe em listas.asteriskbrasil.org>
>
>
>
> _______________________________________________
> KHOMP Inovação: External Board Series
> Módulos de 1/2 rack e 1U para todas as interfaces e soluções Asterisk e FreeSWITCH.
> Tenha a External Series Experience na sua aplicação. Visite www.khomp.com
> _______________________________________________
> DIGIVOICE Fabricante de Placas de Voz e Channel Bank
> 20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM
> Centro Treinamento - Curso de PABX IP - Asterisk - Site www.digivoice.com.br
> ________
> YEALINK: Telefones IP e VídeoPhones IP com o melhor custo/benefício do mercado.
> email: yealink em commlogik.com.br | www.commlogik.com.br | (11) 5503-1011
> ______________________________________________
> Para remover seu email desta lista, basta enviar um email em branco para asteriskbrasil-unsubscribe em listas.asteriskbrasil.org
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: http://listas.asteriskbrasil.org/pipermail/asteriskbrasil/attachments/20121121/355b6435/attachment-0001.htm
Mais detalhes sobre a lista de discussão AsteriskBrasil