[asterisk-users] click2call with AMI?
Muhammad
mohammad.ghazavi at gmail.com
Sat Feb 23 06:55:08 CST 2013
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130223/263c3d64/attachment.htm>
More information about the asterisk-users
mailing list