Jeremy wrote:> Has anyone made, or have any simple PHP, or HTML interfaces where by a user
> could enter their number and the number they want to call, and have
asterisk
> bridge the calls?
>
Yep, see files below.
index.html displays a little form to enter the phone number. It posts
to place-call.php, which creates the appropriate call file. In
accordance with tips from the wiki, it creates the call-file first and
then moves it into the spool folder, in order to avoid concurrency
issues. This file contains the following:
Channel: SIP/224
Callerid: <number entered>
MaxRetries: 1
RetryTime: 60
WaitTime: 30
Context: dial_auto
Extension: <number entered>
Priority: 1
This instructs asterisk to dial SIP/224 with caller-id <number entered>,
and once answered, launches it into <number>@dial_auto:1, this of course
then takes over and dials the number the caller entered. This assures
the person requesting the call that someone's going to be at the other
end when the pick up.
-- index.html --:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Interactive Calling</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form name="calling" method="post"
action="place-call.php">
<table>
<tr>
<td>Phone:</td>
<td><input name="caller" type="text"
id="un">
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit"
value="Call Me Now"></td>
</tr>
</table>
</form>
<br/>Please enter a full 11-digit area code, such as
18005551212.<br/><br/><br/>
</body>
</html>
-- place-call.php --
<?php
error_reporting( E_ALL );
$caller = $_GET[ "caller" ];
if( $caller == "" )
{ $caller = $_POST[ "caller" ]; }
if( $caller == "" )
{ $caller = "18005551212"; }
$station_to_call = "SIP/224";
$spool_dir = "/var/spool/asterisk/outgoing";
$temp_dir = $spool_dir . "/tmp" . $caller;
$call_file = $temp_dir . "/$caller.call";
mkdir( $temp_dir );
$file = fopen( $call_file, "w" );
fputs( $file, "Channel: $station_to_call\n" );
fputs( $file, "Callerid: $caller\n" );
fputs( $file, "MaxRetries: 1\n" );
fputs( $file, "RetryTime: 60\n" );
fputs( $file, "WaitTime: 30\n" );
fputs( $file, "Context: dial_auto\n" );
fputs( $file, "Extension: $caller\n" );
fputs( $file, "Priority: 1\n" );
fclose( $file );
rename( $call_file, $spool_dir."/$caller.call" );
rmdir( $temp_dir );
Header( "302 Moved" );
Header( "Location: index.html" );
?>
and in extensions.conf:
[dial_auto]
exten => _1NXXNXXXXXX,1,SetCallerID(18005551212)
exten => _1NXXNXXXXXX,2,Dial(IAX2/${IAX_1}/1${EXTEN:1},60)
exten => _1NXXNXXXXXX,3,Congestion