<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16809" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>AMI_login($oSocket, '$usuario, $password) . "<br>";</DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>correto -> AMI_login($oSocket, $usuario,
$password) . "<br>";</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>sem a aspa simples antes do $usuario.</FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=lixo@interlinksistemas.com.br
href="mailto:lixo@interlinksistemas.com.br">Sebastiao Rocha</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=asteriskbrasil@listas.asteriskbrasil.org
href="mailto:asteriskbrasil@listas.asteriskbrasil.org">asteriskbrasil@listas.asteriskbrasil.org</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, April 13, 2009 4:44
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [AsteriskBrasil] Script em php
para efetuar chamadas ( http e Shellscript )</DIV>
<DIV><BR></DIV><FONT face=Arial size=2>
<DIV>Obs, fiz a alteração com o intuito de auxiliar, no entanto para uso como
shell script, não realizei os testes após modificar.</DIV>
<DIV><BR>Para utilizar, efetue as seguinte alterações em seu asterisk.</DIV>
<DIV> </DIV>
<DIV>Conteudo do arquivo
/etc/asterisk/manager.conf<BR>------------------------------------------------------------------------------------------<BR>;
AMI - The Asterisk Manager Interface</DIV>
<DIV> </DIV>
<DIV>[general]<BR>displaysystemname = yes<BR>enabled = yes<BR>webenabled =
yes<BR>port = 5038<BR>bindaddr = 0.0.0.0</DIV>
<DIV> </DIV>
<DIV>[admin]<BR>secret = coloque aqui a senha para acesso ao manager
AMI<BR>read=system,call,log,verbose,command,agent,user,config<BR>write=system,call,log,verbose,command,agent,user,config<BR>permit=127.0.0.1;
ou permita o uso via outro computador/rede ex: 192.168.0.0/24</DIV>
<DIV> </DIV>
<DIV>; Authorization for various classes <BR>read =
system,call,log,verbose,command,agent,user,config<BR>write =
system,call,log,verbose,command,agent,user,config<BR>------------------------------------------------------------------------------------------</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Conteudo do arquivo chamada.php "soemnte para envio via
http"<BR>------------------------------------------------------------------------------------------<BR><?php</DIV>
<DIV> </DIV>
<DIV>// Defina aqui as configurações....<BR>$usuario = 'usuario definido no
manager.conf';<BR>$password = 'senha definida no manager.conf';<BR>$context =
'coloque aqui o contexto para efetuar a chamada'<BR>$callerid = 'coloque aqui
o numero que vai aparecer no ramal';</DIV>
<DIV> </DIV>
<DIV>if ( isset( $_POST['telefone']) && isset($_POST['ramal']) )
{<BR> <BR> function AMI_sip_status($socket,
$sip)<BR> {<BR> fputs($socket, "ACTION:
ExtensionState\r\n");<BR> fputs($socket, "Context: ". $context .
"\r\n");<BR> fputs($socket, "Exten: " . $ramal . "\r\n");<BR>
fputs($socket, "ActionID: 1\r\n\r\n");<BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> <BR> return
fgets($socket);<BR> }<BR> <BR> function AMI_originate($socket,
$phonenumber)<BR> {<BR> fputs($socket, "Action:
originate\r\n");<BR> fputs($socket, "Timeout: 30000\r\n");<BR>
fputs($socket, "CallerId: " . $callerid <$phonenumber>\r\n");<BR>
fputs($socket, "RetryTime: 45\r\n");<BR> fputs($socket, "WaitTime:
30\r\n");<BR> fputs($socket, "Channel: SIP/" . $ramal .
"\r\n");<BR> fputs($socket, "Exten: $phonenumber\r\n");<BR>
fputs($socket, "Context: ". $context . "\r\n");<BR> fputs($socket,
"Priority: 1\r\n");<BR> fputs($socket, "ActionID:
1\r\n\r\n");<BR> <BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket); <BR>
fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> <BR> $result = fgets($socket);<BR> echo
$result; <BR> }<BR> <BR> function
AMI_login($socket, $username, $password)<BR> {<BR> fputs($socket,
"Action: login\r\n");<BR> fputs($socket, "Username:
$username\r\n");<BR> fputs($socket, "Secret:
$password\r\n\r\n");<BR> fputs($socket, "Events:
off\r\n\r\n");<BR> <BR> return
fgets($socket);<BR> }<BR> <BR> if ( isset($_POST['telefone'])
&& inset($_POST['ramal']) ) {<BR> $number =
strtolower($_POST['telefone']); // Número a chamar<BR> $ramal =
$_POST['ramal']; // Ramal que será chamado ao ser atendida a chamada
efetuada.<BR> $errno = 0;<BR> $errstr = 0;<BR> <BR>
$oSocket = fsockopen("localhost", 5038, &$errno, &$errstr,
20);<BR> if (!$oSocket)<BR> {<BR> echo "Não foi
poss&iacute;vel completar a chamada...";<BR> }<BR>
else<BR> {<BR> fgets($oSocket);<BR> <BR>
AMI_login($oSocket, '$usuario, $password) . "<br>";<BR>
AMI_originate($oSocket, $number) . "<br>";<BR> <BR>
fputs($oSocket, "Action: Logoff\r\n\r\n");<BR>
fclose($oSocket);<BR> }<BR> }<BR>}<BR><?php</DIV>
<DIV> </DIV>
<DIV><BR>Conteudo do arquivo chamada.php "somente para envio via shell
script"</DIV>
<DIV>------------------------------------------------------------------------------------------<BR>#!/usr/bin/php
-q</DIV>
<DIV> </DIV>
<DIV><?php<BR>//Como utilizar: <BR>// ./chamada.php telefone
ramal<BR>// ./chamada.php 03432564400 2000</DIV>
<DIV> </DIV>
<DIV>// Defina aqui as configurações....<BR>$usuario = 'usuario definido no
manager.conf';<BR>$password = 'senha definida no manager.conf';<BR>$context =
'coloque aqui o contexto para efetuar a chamada'<BR>$callerid = 'coloque aqui
o numero que vai aparecer no ramal';</DIV>
<DIV> </DIV>
<DIV>if ( isset( $argv[1] ) && isset($argv[2]) )
{<BR> <BR> function AMI_sip_status($socket,
$sip)<BR> {<BR> fputs($socket, "ACTION:
ExtensionState\r\n");<BR> fputs($socket, "Context: ". $context .
"\r\n");<BR> fputs($socket, "Exten: " . $ramal . "\r\n");<BR>
fputs($socket, "ActionID: 1\r\n\r\n");<BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> <BR> return
fgets($socket);<BR> }<BR> <BR> function AMI_originate($socket,
$phonenumber)<BR> {<BR> fputs($socket, "Action:
originate\r\n");<BR> fputs($socket, "Timeout: 30000\r\n");<BR>
fputs($socket, "CallerId: " . $callerid <$phonenumber>\r\n");<BR>
fputs($socket, "RetryTime: 45\r\n");<BR> fputs($socket, "WaitTime:
30\r\n");<BR> fputs($socket, "Channel: SIP/" . $ramal .
"\r\n");<BR> fputs($socket, "Exten: $phonenumber\r\n");<BR>
fputs($socket, "Context: ". $context . "\r\n");<BR> fputs($socket,
"Priority: 1\r\n");<BR> fputs($socket, "ActionID:
1\r\n\r\n");<BR> <BR> fgets($socket);<BR>
fgets($socket);<BR> fgets($socket); <BR>
fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR>
fgets($socket);<BR> <BR> $result = fgets($socket);<BR> echo
$result; <BR> }<BR> <BR> function
AMI_login($socket, $username, $password)<BR> {<BR> fputs($socket,
"Action: login\r\n");<BR> fputs($socket, "Username:
$username\r\n");<BR> fputs($socket, "Secret:
$password\r\n\r\n");<BR> fputs($socket, "Events:
off\r\n\r\n");<BR> <BR> return
fgets($socket);<BR> }<BR> <BR> if ( isset($_POST['telefone'])
&& inset($_POST['ramal']) ) {<BR> $number =
strtolower($argv[1]); // Número a chamar<BR> $ramal = $argv[2]; // Ramal
que será chamado ao ser atendida a chamada efetuada.<BR> $errno =
0;<BR> $errstr = 0;<BR> <BR> $oSocket =
fsockopen("localhost", 5038, &$errno, &$errstr, 20);<BR> if
(!$oSocket)<BR> {<BR> echo "Não foi poss&iacute;vel
completar a chamada...";<BR> }<BR> else<BR>
{<BR> fgets($oSocket);<BR> <BR>
AMI_login($oSocket, '$usuario, $password) . "<br>";<BR>
AMI_originate($oSocket, $number) . "<br>";<BR> <BR>
fputs($oSocket, "Action: Logoff\r\n\r\n");<BR>
fclose($oSocket);<BR> }<BR> }<BR>}</DIV>
<DIV> </DIV>
<DIV>?></FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=rguedesdecarvalho@gmail.com
href="mailto:rguedesdecarvalho@gmail.com">Ricardo Guedes de Carvalho</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=asteriskbrasil@listas.asteriskbrasil.org
href="mailto:asteriskbrasil@listas.asteriskbrasil.org">asteriskbrasil@listas.asteriskbrasil.org</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, April 13, 2009 4:26
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [AsteriskBrasil]script
para realizar ligação no asterisk (AGI)</DIV>
<DIV><BR></DIV>ok, vou testar aki...só uma pergunta, esse arquivo
chamada.php deve estar localizado em /var/www/ certo?<BR><BR>
<DIV class=gmail_quote>2009/4/13 Sebastiao Rocha <SPAN dir=ltr><<A
href="mailto:lixo@interlinksistemas.com.br">lixo@interlinksistemas.com.br</A>></SPAN><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<DIV bgcolor="#ffffff">
<DIV><FONT face=Arial size=2><SPAN lang=PT-BR><SPAN lang=PT-BR>
<P>Para utilizar, efetue as seguinte alterações em seu asterisk.</P>
<P>Conteudo do arquivo
/etc/asterisk/manager.conf<BR>------------------------------------------------------------------------------------------<BR>;
AMI - The Asterisk Manager Interface</P>
<P>[general]<BR>displaysystemname = yes<BR>enabled = yes<BR>webenabled =
yes<BR>port = 5038<BR>bindaddr = 0.0.0.0</P>
<P>[admin]<BR>secret = coloque aqui a senha para acesso ao manager
AMI<BR>read=system,call,log,verbose,command,agent,user,config<BR>write=system,call,log,verbose,command,agent,user,config<BR>permit=127.0.0.1;
ou permita o uso via outro computador/rede ex: <A
href="http://192.168.0.0/24" target=_blank>192.168.0.0/24</A></P>
<P>; Authorization for various classes <BR>read =
system,call,log,verbose,command,agent,user,config<BR>write =
system,call,log,verbose,command,agent,user,config<BR>------------------------------------------------------------------------------------------</P></SPAN>
<P> </P>
<P>AMI_login($oSocket, 'usuario', 'senha') .
"<br>";<BR></P></SPAN></FONT><FONT face=Arial size=2>Conteudo do
arquivo
chamada.php<BR>------------------------------------------------------------------------------------------<BR></FONT><FONT
face=Arial size=2><?php</FONT>
<P><FONT face=Arial size=2>$usuario = 'usuario definido no
manager.conf';<BR></FONT><FONT face=Arial size=2>$password = 'senha
definida no manager.conf';</FONT></P></DIV>
<DIV><FONT face=Arial size=2>if ( isset( $_POST['telefone']) &&
isset($_POST['ramal']) ) {</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> function AMI_sip_status($socket,
$sip)<BR> {<BR> fputs($socket, "ACTION:
ExtensionState\r\n");<BR> fputs($socket, "Context:
interlink\r\n");<BR> fputs($socket, "Exten: " . $ramal .
"\r\n");<BR> fputs($socket, "ActionID:
1\r\n\r\n");<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> return
fgets($socket);<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> function AMI_originate($socket,
$phonenumber)<BR> {<BR> fputs($socket, "Action:
originate\r\n");<BR> fputs($socket, "Timeout:
30000\r\n");<BR> fputs($socket, "CallerId: Site Interlink
<$phonenumber>\r\n");<BR> fputs($socket, "RetryTime:
45\r\n");<BR> fputs($socket, "WaitTime:
30\r\n");<BR> fputs($socket, "Channel: SIP/" . $ramal .
"\r\n");<BR> fputs($socket, "Exten:
0$phonenumber\r\n");<BR> fputs($socket, "Context:
interlink\r\n");<BR> fputs($socket, "Priority:
1\r\n");<BR> fputs($socket, "ActionID:
1\r\n\r\n");</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2> fgets($socket);<BR> fgets($socket);<BR> fgets($socket); <BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> fgets($socket);<BR> <BR> $result
= fgets($socket);<BR> echo
$result; <BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> function AMI_login($socket, $username,
$password)<BR> {<BR> fputs($socket, "Action:
login\r\n");<BR> fputs($socket, "Username:
$username\r\n");<BR> fputs($socket, "Secret:
$password\r\n\r\n");<BR> fputs($socket, "Events:
off\r\n\r\n");</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> return
fgets($socket);<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> if ( isset($_POST['telefone'])
&& inset($_POST['ramal']) ) {<BR> $number =
strtolower($_POST['telefone']); // Número a chamar</FONT></DIV>
<DIV><FONT face=Arial size=2> $ramal = $_POST['telefone']; //
Ramal que será chamado ao ser atendida a chamada efetuada.</FONT></DIV>
<DIV><FONT face=Arial size=2> $errno =
0;<BR> $errstr = 0;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> $oSocket = fsockopen("localhost",
5038, &$errno, &$errstr, 20);<BR> if
(!$oSocket)<BR> {<BR> echo "Não foi
poss&iacute;vel completar a
chamada...";<BR> }<BR> else<BR> {<BR> fgets($oSocket);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> AMI_login($oSocket,
'$usuario, $password) .
"<br>";<BR> AMI_originate($oSocket, $number) .
"<br>";</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> fputs($oSocket, "Action:
Logoff\r\n\r\n");<BR> fclose($oSocket);<BR> }<BR> }<BR>}</FONT></DIV>
<DIV><FONT face=Arial
size=2><?php</FONT></DIV></DIV></BLOCKQUOTE></DIV></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>Openmoko Freerunner,
primeiro telefone open source, disponível no Brasil rodando o Android da
Google.<BR>http://www.neodroid.com<BR><BR>Compre uma camiseta da
AsteriskBrasil.org!<BR>http://www.voipmania.com.br<BR><BR>Acesse o canal IRC
de discussão sobre Asterisk em Português Brasileiro na rede Freenode.net:
#asterisk-br<BR>_______________________________________________<BR>Lista de
discussões
AsteriskBrasil.org<BR>AsteriskBrasil@listas.asteriskbrasil.org<BR>http://listas.asteriskbrasil.org/mailman/listinfo/asteriskbrasil</BLOCKQUOTE></BODY></HTML>