[Freeswitch-users] working PHP script with socket

Gopal krishnan saigop at gmail.com
Thu Sep 25 00:48:56 PDT 2008


Hi,

Outbound call went thru socket with the PHP program. The program as follows,

<?php
$Caller = htmlspecialchars($_POST['Caller']);
$Callee = htmlspecialchars($_POST['Callee']);
echo "Php now!<br>";
echo "Caller is: $Caller<br>";
echo "Callee is: $Callee<br>";

$handle = fsockopen('127.0.0.1', '8021', $erno, $errstr, 30);
if (!$handle) {
 //if connection fails exit and tell us what went wrong.
 die("Connect failed with erno $erno and errstr $errstr\n");
}
else {
 //read the first line the smtp server gives us (usually the version string)
 //$responses = fgets($handle, 1024);
 $response= fread($handle, 1024);
 echo "connection opened, got response:<br> $response<br><br>";

 $authMessage = "auth ClueCon\r\n\r\n";
 fwrite($handle, "$authMessage");


 $response = fread($handle, 1024);
 echo "authMessage sent, got response:<br> $response<br>";


 $command = "api originate sofia/default/$Callee@<freeswitch IP address>
$Caller \r\n\r\n";

 echo "command is $command";
 fwrite($handle, $command);

 $response = fread($handle, 1024);
 echo "command sent, got response:<br> $response<br>";
 $response = fread($handle, 1024);
 echo "command sent, got response:<br> $response<br>";


 //fclose($handle);
 }
}
?>

Thanks

-- 
Thank you with regards,
Gopal,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20080925/4dcc3267/attachment-0002.html 


More information about the FreeSWITCH-users mailing list