Click 2 Call using AMI

Chilling_Silence

Joined
Sep 23, 2008
Messages
488
Likes
0
Points
0
#1
So Ive been using the following code, along with a URL similar to this:
Click2Call2.php?exten=SIP/309&number=123456789

<?php
#ip address that asterisk is on.
$strHost = "127.0.0.1";#specify the username you want to login with
$strUser = "admin";#specify the password for the above user
$strSecret = "elastix456";

#specify the channel (extension) you want to receive the call requests with
#e.g. SIP/XXX, IAX2/XXXX, ZAP/XXXX, etc
# $strChannel = "SIP/209";
$strChannel = $_REQUEST['exten'];

$strContext = "from-internal";

#specify the amount of time you want to try calling the specified channel before hangin up
$strWaitTime = "30";

#specify the priority you wish to place on making this call
$strPriority = "1";

#specify the maximum amount of retries
$strMaxRetry = "2";

$number=strtolower($_REQUEST['number']);
$pos=strpos ($number,"local");
if ($number == null) :
exit() ;
endif ;
if ($pos===false) :
$errno=0 ;
$errstr=0 ;
$strCallerId = "Web Call $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: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $number\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(2);
fclose($oSocket);
}
echo "Extension $strChannel should be calling $number." ;
else :
exit() ;
endif ;
?>
It a great little proof-of-concept Click-to-Call dialer.
My only question is, Ive been looking here:
http://www.voip-info.org/wiki/view/Asterisk+manager+API

But Im not entirely sure how I can get it to first call an external number, and then a second external number?

Or perhaps first dial a Ring Group, and then dial the external number.
Is this possible? I have a feeling I'd probably only need to change one or two lines, but Im not entirely sure what.

Thanks


Chill.
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,886
Members
17,563
Latest member
dineshr
Top