Hi,
I have a PHP code with AMI to using in click2call system.

here is my code:
    $user    = "usernamr";
    $secret  = "secret";
    $channel = 'SIP/' . $sip;

     $context = "from-internal";

    $waitTime = "20";
    $timeout = 20000;

    $priority = "1";

    $maxRetry = "2";

    $pos      = strpos($number, "local");
    if ($number == null):
        exit();
    endif;
    if ($pos === false) :
        $errno    = 0;
        $errstr   = 0;
        $callerId = $number;
        $oSocket  = fsockopen("localhost", 5038, &$errno, &$errstr, 20);
        if (!$oSocket)
        {
            echo "$errstr ($errno)<br>\n";
        } else
        {
            fputs($oSocket, "Action: login\r\n");
            fputs($oSocket, "Events: on\r\n");
            fputs($oSocket, "Username: $user\r\n");
            fputs($oSocket, "Secret: $secret\r\n\r\n");
            fputs($oSocket, "Action: originate\r\n");
            fputs($oSocket, "Channel: $channel\r\n");
            fputs($oSocket, "WaitTime: $waitTime\r\n");
            fputs($oSocket, "CallerId: $callerId\r\n");
            fputs($oSocket, "Exten: $number\r\n");
            fputs($oSocket, "Context: $context\r\n");
            fputs($oSocket, "Priority: $priority\r\n\r\n");
            fputs($oSocket, "Async: yes\r\n\r\n");
            fputs($oSocket, "Action: Logoff\r\n\r\n");
            sleep(2);
            fclose($oSocket);
        }
    else :

    endif;

most of the time it tell me NO ANSWER when click2call number, but in normal
way it's ok and ringing phone and ANSWER.
my code is ok or not? and what is best way to click2call.
I think .call file is ok to making click2call system.
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to