<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="IncrediMail 1.0" name=GENERATOR>
<STYLE>v\:* {
        BEHAVIOR: url (#default#vml)
}
</STYLE>

<STYLE>v\:* {
        BEHAVIOR: url (#default#vml)
}
</STYLE>

<style>v\:* {
        BEHAVIOR: url (#default#vml)
}
</style>
<!--IncrdiXMLRemarkStart>
<IncrdiX-Info>
<X-FID>B433CDFE-B71C-42C2-A5C1-D34C076A9851</X-FID>
<X-FVER>4,000000</X-FVER>
<X-FIT>Letter</X-FIT>
<X-FILE>signing_pen.imf</X-FILE>
<X-FCOL>Business</X-FCOL>
<X-FCAT>Stationery</X-FCAT>
<X-FDIS>Signing Pen</X-FDIS>
<X-Extensions>SU1CTDEsNDYsgUmBSTCJlZU0KDgsTTCdhTRNiZE0kU0kjTSFTSiViTSBnZkkxcGNhUmBSYFJgSxJTUJMMiwwLCxJTUJMMywwLCw=</X-Extensions>
<X-BG>cid:1DF450B0-0865-4C69-8B41-EC851558A38B</X-BG>
<X-BGT>no-repeat</X-BGT>
<X-BGC>#ffffff</X-BGC>
<X-BGPX>right</X-BGPX>
<X-BGPY>bottom</X-BGPY>
<X-ASN></X-ASN>
<X-ASNF></X-ASNF>
<X-ASH></X-ASH>
<X-ASHF></X-ASHF>
<X-AN></X-AN>
<X-ANF></X-ANF>
<X-AP></X-AP>
<X-APF></X-APF>
<X-AD></X-AD>
<X-ADF></X-ADF>
<X-AUTO>X-ASN,X-ASH,X-AN,X-AP,X-AD</X-AUTO>
<X-CNT>;</X-CNT>
</IncrdiX-Info>
<IncrdiXMLRemarkEnd-->
</HEAD>
<BODY style="BACKGROUND-POSITION: right bottom; FONT-SIZE: 12pt; MARGIN: 0px 150px 10px 10px; COLOR: #1c3966; BACKGROUND-REPEAT: no-repeat; FONT-FAMILY: Verdana" text=#1c3966 bgProperties=fixed bgColor=#ffffff background=cid:1DF450B0-0865-4C69-8B41-EC851558A38B scroll=yes SIGCOLOR="11031552" INCREDIFIXEDFORIMOL="true">
<TABLE id=INCREDIMAINTABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD id=INCREDITEXTREGION dir=ltr style="FONT-SIZE: 12pt; DIRECTION: ltr" vAlign=top width="100%">
<DIV>Boa tarde amigos,</DIV>
<DIV dir=ltr>
<DIV>&nbsp;</DIV>
<DIV>Como eu havia procurado há um tempo atrás&nbsp;um script php para click-to-call e não tive sucesso, ontem consegui um bem simples.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Segue abaixo código&nbsp;para quem precisar ou quiser estudá-lo.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>==========================================================</DIV>
<DIV>==========================================================</DIV>
<DIV><FONT face=Courier>&lt;html&gt;<BR>&lt;head&gt;<BR>&lt;title&gt;Clique para Falar - NGN Soluções WebCall&lt;/title&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&lt;?<BR>#Click-To-Call script NGN-Billing</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><BR><FONT face=Courier>#------------------------------------------------------------------------------------------<BR>#edite as variáveis para refletir com o seu sistema<BR>#------------------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#informe o endereço ip do seu asterisk<BR><BR>$strHost = "127.0.0.1";</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#especifique o usuario que ira conectar ao&nbsp;CLI&nbsp;(deve estar definido em&nbsp;/etc/asterisk/manager.conf)<BR>$strUser = "admin";</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#senha para o usuario acima<BR>$strSecret = "adminpass";</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#especifique o canal&nbsp;(extension) que vc deseja receber estas ligações<BR>#exemplo: SIP/XXX, IAX2/XXXX, ZAP/XXXX, <BR>$strChannel = "SIP/".$_POST['txtOrigem'];</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#informe o contexto que irá processar a ligação&nbsp;para PSTN<BR>$strContext = "web-to-pstn";</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#especifique a prioridade do contexto acima</FONT></DIV>
<DIV><FONT face=Courier>$strPriority = "1";</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#especifique a quantidade de tentativas</FONT></DIV>
<DIV><FONT face=Courier>$strMaxRetry = "2";</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#--------------------------------------------------------------------------------------------<BR>#Não precisa editar mais nada a partir daqui para fazer esse script funfar<BR>#--------------------------------------------------------------------------------------------<BR>#obtem o número a ser discado<BR>$strExten = $_POST['txtDestino'];</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>#especifica um callerid para a ligação<BR>$strCallerId = "WebCall de &lt;".$_POST['txtOrigem']."&gt;";</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>$length = len($strExten);</FONT></DIV>
<DIV><FONT face=Courier>&nbsp;</FONT></DIV>
<DIV><FONT face=Courier>if ($length == 11 &amp;&amp;&nbsp; id_number($_POST['txtDestino'])){</FONT></DIV>
<DIV><FONT face=Courier>$oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Erro na conexão com o Servidor!");<BR>fputs($oSocket, "Action: login\r\n");<BR>fputs($oSocket, "Events: off\r\n");<BR>fputs($oSocket, "Username: $strUser\r\n");<BR>fputs($oSocket, "Secret: $strSecret\r\n\r\n");<BR>fputs($oSocket, "Action: originate\r\n");<BR>fputs($oSocket, "Channel: $strChannel\r\n");<BR>fputs($oSocket, "CallerId: $strCallerId\r\n");<BR>fputs($oSocket, "Exten: $strExten\r\n");<BR>fputs($oSocket, "Context: $strContext\r\n");<BR>fputs($oSocket, "Priority: $strPriority\r\n\r\n");<BR>fputs($oSocket, "Action: Logoff\r\n\r\n");<BR>$wrtes = fgets($oSocket, 2048);<BR>echo $wrtes."&lt;br /&gt;";<BR>fclose($oSocket);<BR>&nbsp;&nbsp;&nbsp; ?&gt;<BR>&lt;p&gt;<BR>&lt;table width="300" border="1" bordercolor="#630000" cellpadding="3" cellspacing="0"&gt;<BR>&nbsp;&lt;tr&gt;&lt;td&gt;<BR>&nbsp;&lt;font size="2" face="verdana,georgia" color="#630000"&gt;Estamos tentando fazer a ligação.&lt;br&gt;Aguarde alguns instantes...&lt;br&gt;&lt;a href="&lt;? echo $_SERVER['PHP_SELF'] ?&gt;"&gt;Ligar novamente&lt;/a&gt;&lt;/font&gt;<BR>&nbsp;&lt;/td&gt;&lt;/tr&gt;<BR>&lt;/table&gt;<BR>&lt;/p&gt;<BR>&lt;?<BR>}<BR>else<BR>{<BR>?&gt;<BR>&lt;p&gt;<BR>&lt;table width="300" border="1" bordercolor="#630000" cellpadding="3" cellspacing="0"&gt;<BR>&nbsp;&lt;tr&gt;&lt;td&gt;<BR>&nbsp;&lt;font size="2" face="verdana,arial,georgia" color="#630000"&gt;Número de telefone a ser discado (0(XX)XXXX-XXXX)!&lt;/font&gt;<BR>&nbsp;&lt;form action="&lt;? echo $_SERVER['PHP_SELF'] ?&gt;" method="post"&gt;<BR>&nbsp;&nbsp;Ramal&lt;input type="text" size="20" name="txtOrigem"&gt;&lt;br&gt;<BR>&nbsp;&nbsp;Destino&lt;input type="text" size="20" name="txtDestino"&gt;&lt;br&gt;<BR>&nbsp;&nbsp;&lt;input type="submit" value="Iniciar ligação"&gt;<BR>&nbsp;&lt;/form&gt;<BR>&nbsp;&lt;/td&gt;&lt;/tr&gt;<BR>&lt;/table&gt;<BR>&lt;/p&gt;<BR>&lt;?<BR>}<BR>?&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>=======================================================================</DIV>
<DIV>&nbsp;</DIV>
<DIV>Att,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Fernando da Silva Santos</DIV>
<DIV>NGN Soluções - <A href="http://www.ngnsolucoes.com.br">www.ngnsolucoes.com.br</A></DIV>
<DIV>MSN/E-Mail: <A href="mailto:noc@ngnsolucoes.com.br">noc@ngnsolucoes.com.br</A><BR></DIV></DIV></TD></TR>
<TR>
<TD id=INCREDIFOOTER width="100%">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD width="100%"></TD>
<TD id=INCREDISOUND vAlign=bottom align=middle></TD>
<TD id=INCREDIANIM vAlign=bottom align=middle></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>