<div dir="ltr">Hi,<br>I have a PHP code with AMI to using in click2call system.<br><br>here is my code:<br> $user = "usernamr";<br> $secret = "secret";<br> $channel = 'SIP/' . $sip;<br>
<br> $context = "from-internal";<br><br> $waitTime = "20";<br> $timeout = 20000;<br><br> $priority = "1";<br><br> $maxRetry = "2";<br><br> $pos = strpos($number, "local");<br>
if ($number == null):<br> exit();<br> endif;<br> if ($pos === false) :<br> $errno = 0;<br> $errstr = 0;<br> $callerId = $number;<br> $oSocket = fsockopen("localhost", 5038, &$errno, &$errstr, 20);<br>
if (!$oSocket)<br> {<br> echo "$errstr ($errno)<br>\n";<br> } else<br> {<br> fputs($oSocket, "Action: login\r\n");<br> fputs($oSocket, "Events: on\r\n");<br>
fputs($oSocket, "Username: $user\r\n");<br> fputs($oSocket, "Secret: $secret\r\n\r\n");<br> fputs($oSocket, "Action: originate\r\n");<br> fputs($oSocket, "Channel: $channel\r\n");<br>
fputs($oSocket, "WaitTime: $waitTime\r\n");<br> fputs($oSocket, "CallerId: $callerId\r\n");<br> fputs($oSocket, "Exten: $number\r\n");<br> fputs($oSocket, "Context: $context\r\n");<br>
fputs($oSocket, "Priority: $priority\r\n\r\n");<br> fputs($oSocket, "Async: yes\r\n\r\n");<br> fputs($oSocket, "Action: Logoff\r\n\r\n");<br> sleep(2);<br>
fclose($oSocket);<br> }<br> else :<br><br> endif;<br><br>most of the time it tell me NO ANSWER when click2call number, but in normal way it's ok and ringing phone and ANSWER.<br>my code is ok or not? and what is best way to click2call.<br>
I think .call file is ok to making click2call system.<br></div>