<!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><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: 192.168.0.0/24</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></SPAN></FONT><FONT face=Arial size=2>Conteudo do arquivo
chamada.php<BR>------------------------------------------------------------------------------------------<BR></FONT><FONT
face=Arial size=2><?php</FONT></P>
<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></BODY></HTML>