Call file generated from a PHP file

<?php

$destination = $_SERVER['QUERY_STRING'];

// locations
$tmp = "/var/spool/asterisk/tmp/";
$outgoing = "/var/spool/asterisk/outgoing/";

// .call Template
$callFile = file_get_contents($tmp.'in4.call');

// String Replace
$callFile = str_replace("##DESTINATION##","$destination",$callFile);


$tmpFile = uniqid().".call";
$fh = fopen($tmp.$tmpFile, 'w');
fwrite($fh, $callFile);
fclose($fh);

rename($tmp.$tmpFile, $outgoing.$tmpFile);


//echo "<script language='javascript'><!--setTimeout("window.history.go(-1)",5000);//--> </script>";
echo "Complete!";

This PHP file is smashing. It edits a pre-existing call file with a variable passed in the URL then moves it into the spool folder for immediate dialling. I am trying unsuccessfully to add some JavaScript to the resulting output so that once it has done its magic, the user who clicks the link is returned to the page they were viewing. I am so far unsuccessful in this attempt, despite trying various different ways of embedding the JavaScript. I’m sure it’s something really simple I’m doing wrong. If anyone has a moment to point me in the right direction I’d be hugely grateful.

Thank you

You can also initiate outbound calls immediately using AMI without generating a call file as is done in this script: https://github.com/lgaetz/Jolt-Select-Dial-PBX/blob/master/freepbx_call.php

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.