[asterisk-users] PHP to call script
zero massive
thezerogroup at gmail.com
Fri Dec 29 08:46:00 MST 2006
Using the php script below. I am able to enter my number and the number to
call, however I get the following error:
-- AGI Script cid-spoof.agi completed, returning 0
== Parsing '/etc/asterisk/manager.conf': Found
== Parsing '/etc/asterisk/manager_custom.conf': Found
== Manager 'admin' logged on from 127.0.0.1
-- Executing Wait("OutgoingSpoolFailed", "4") in new stack
-- Executing BackGround("OutgoingSpoolFailed", "beep") in new stack
== Spawn extension (custom-web-dial-both-called, failed, 2) exited
non-zero on 'OutgoingSpoolFailed'
-- Executing Hangup("OutgoingSpoolFailed", "") in new stack
== Spawn extension (custom-web-dial-both-called, h, 1) exited non-zero on
'OutgoingSpoolFailed'
== Manager 'admin' logged off from 127.0.0.1
Here is the PHP:
<html>
<head>
<title>Call From Web!</title>
</head>
<body>
<?
#------------------------------------------------------------------------------------------
#edit the below variable values to reflect your system/information
#------------------------------------------------------------------------------------------
#specify the name/ip address of your asterisk box
#if your are hosting this page on your asterisk box, then you can use
#127.0.0.1 as the host IP. Otherwise, you will need to edit the following
#line in manager.conf, under the Admin user section:
#permit=127.0.0.1/255.255.255.0
#change to:
#permit=127.0.0.1/255.255.255.0,xxx.xxx.xxx.xxx ;(the ip address of the
server this page is running on)
$strHost = "127.0.0.1";
#specify the username you want to login with (these users are defined in
/etc/asterisk/manager.conf)
#this user is the default AAH AMP user; you shouldn't need to change, if
you're using AAH.
$strUser = "admin";
#specify the password for the above user
$strSecret = "amp111";
####-----This block is not used in this script----###
#specify the channel (extension) you want to receive the call requests with
#e.g. SIP/XXX, IAX2/XXXX, ZAP/XXXX, etc
#$strChannel = "IAX2/XXXXXX";
#specify the context to make the outgoing call from. By default, AAH uses
from-internal
#Using from-internal will make you outgoing dialing rules apply
#$strContext = "from-internal";
####---End of block---###
#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";
#--------------------------------------------------------------------------------------------
#Should edit some things below this point to make this script work
#--------------------------------------------------------------------------------------------
#get the caller's number from the form
$strCallerNumber = $_POST['txtcallernumber'];
$strChannel = $strCallerNumber;
$strCallerId = $strCallerNumber;
#get the phone number from the posted form
$strExten = $_POST['txtphonenumber'];
$callNumber = $strExten;
#specify the caller id for the call
$strCallerId = "Web will call <$callNumber>";
$length = strlen($strExten);
if ($length == 10 && is_numeric($strExten))
{
$oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Connection
to host failed");
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:
SIP/Telasip-gw4/$strChannel at custom-web-dial-both\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $callNumber\r\n");
fputs($oSocket, "Context: custom-web-dial-both-called\r\n");
fputs($oSocket, "Priority: 1\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
fclose($oSocket);
?>
<p>
<table width="300" border="1" bordercolor="#0f0f0f" cellpadding="3"
cellspacing="0">
<tr><td>
<font size="2" face="verdana,georgia"
color="#000000">Processing call. Please wait.
</font>
</td></tr>
</table>
<?
}
else
{
?>
<p>
<table width="300" border="1" bordercolor="#0f0f0f" cellpadding="3"
cellspacing="0">
<tr><td>
<form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post">
<font size="2" face="verdana,arial,georgia" color="#000000">
Enter the number you are calling from:</font>
<input type="text" size="20" maxlength="10" name="txtcallernumber"><br>
<font size="2" face="verdana,arial,georgia" color="#000000">
Enter the number where you want to call:</font>
<input type="text" size="20" maxlength="10" name="txtphonenumber"><br>
<input type="submit" value="Make Call">
</form>
</td></tr>
</table>
</p>
<?
}
?>
</body>
</html>
Here is the whats in my .confs
[custom-web-dial-both]
include => outbound-allroutes
[custom-web-dial-both-called]
exten => _.,1,Wait(4)
exten => _.,2,Background(beep)
include => outbound-allroutes
exten => h,1,Hangup
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20061229/a205309f/attachment.htm
More information about the asterisk-users
mailing list