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><br>_______________________________________________<br>Openmoko Freerunner, primeiro telefone open source, disponível no Brasil rodando o Android da Google.<br>
<a href="http://www.neodroid.com/" target="_blank">http://www.neodroid.com</a><br><br>Compre uma camiseta da AsteriskBrasil.org!<br><a href="http://www.voipmania.com.br/" target="_blank">http://www.voipmania.com.br</a><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><a href="mailto:AsteriskBrasil@listas.asteriskbrasil.org">AsteriskBrasil@listas.asteriskbrasil.org</a><br>
<a href="http://listas.asteriskbrasil.org/mailman/listinfo/asteriskbrasil" target="_blank">http://listas.asteriskbrasil.org/mailman/listinfo/asteriskbrasil</a><br></blockquote></div><br><br clear="all"><br>-- <br>Ricardo Guedes<br>
Suporte Telefonia Voz sobre IP<br>IGNISCOM (19) 3119-2445<br>