<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    = &quot;usernamr&quot;;<br>    $secret  = &quot;secret&quot;;<br>    $channel = &#39;SIP/&#39; . $sip;<br>

<br>     $context = &quot;from-internal&quot;;<br><br>    $waitTime = &quot;20&quot;;<br>    $timeout = 20000;<br><br>    $priority = &quot;1&quot;;<br><br>    $maxRetry = &quot;2&quot;;<br><br>    $pos      = strpos($number, &quot;local&quot;);<br>

    if ($number == null):<br>        exit();<br>    endif;<br>    if ($pos === false) :<br>        $errno    = 0;<br>        $errstr   = 0;<br>        $callerId = $number;<br>        $oSocket  = fsockopen(&quot;localhost&quot;, 5038, &amp;$errno, &amp;$errstr, 20);<br>

        if (!$oSocket)<br>        {<br>            echo &quot;$errstr ($errno)&lt;br&gt;\n&quot;;<br>        } else<br>        {<br>            fputs($oSocket, &quot;Action: login\r\n&quot;);<br>            fputs($oSocket, &quot;Events: on\r\n&quot;);<br>

            fputs($oSocket, &quot;Username: $user\r\n&quot;);<br>            fputs($oSocket, &quot;Secret: $secret\r\n\r\n&quot;);<br>            fputs($oSocket, &quot;Action: originate\r\n&quot;);<br>            fputs($oSocket, &quot;Channel: $channel\r\n&quot;);<br>

            fputs($oSocket, &quot;WaitTime: $waitTime\r\n&quot;);<br>            fputs($oSocket, &quot;CallerId: $callerId\r\n&quot;);<br>            fputs($oSocket, &quot;Exten: $number\r\n&quot;);<br>            fputs($oSocket, &quot;Context: $context\r\n&quot;);<br>

            fputs($oSocket, &quot;Priority: $priority\r\n\r\n&quot;);<br>            fputs($oSocket, &quot;Async: yes\r\n\r\n&quot;);<br>            fputs($oSocket, &quot;Action: Logoff\r\n\r\n&quot;);<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&#39;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>