[asterisk-users] click to call with php

A J Stiles asterisk_list at earthshod.co.uk
Fri May 20 05:41:17 CDT 2011


On Friday 20 May 2011, salaheddine elharit wrote:
> Ok thank you so much for all advice

This might help you a bit, too:

<?php
$spool = "/var/spool/asterisk/outgoing/"; # outgoing callfile folder

$filename = "asterisk-" . date("U") . "-" . $_SERVER["REMOTE_PORT"] . ".call"; 
# this should end up being fairly unique.  (if logging to a database with an
# auto increment field, you can also use mysql_insert_id() as a unique
# reference)

$src = ... ; # source extension
# you can determine this based on $_SERVER["REMOTE_ADDR"], which is the
# IP address of the requesting client, by looking up in an array or a database
$ctxt = ... ; # context
$dest = ... ; # destination number
# you probably want to get this from $_REQUEST

$callfile = "Channel: SIP/$src\nContext: $ctxt\nExtension: $dest\nPriority: 
1\nCallerId: $src\n"; # line break added by email, not used in real life!
if ($fh = fopen("/tmp/$filename", "w")) {
    fwrite($fh, $callfile);
    fclose($fh);
    system("mv /tmp/$filename $spool");
}
else {
    die("Call file creation failed");
};
?>

-- 
AJS

Answers come *after* questions.



More information about the asterisk-users mailing list