2 ways calls example
credit: I found from http://samyantoun.50webs.com/asterisk/athome/2waycall.htm
s,1,Playback(pls-wait-connect-call)
// exten => s,2,Macro(dialout-trunk,5,${CALLERIDNUM},)
// exten => s,3,Macro(outisbusy)
$fromnumber=strtolower($_REQUEST['from']);
$pos=strpos ($fromnumber,"local");
$tonumber=strtolower($_REQUEST['to']);
if ($fromnumber == null) :
exit();
endif;
if ($pos===false) :
$errno=0;
$errstr=0;
$fp = fsockopen ("localhost", 5038, &$errno, &$errstr, 20);
if (!$fp) {
echo "$errstr ($errno)
\n";
}
else {
fputs ($fp, "Action: login\r\n");
fputs ($fp, "Username: phpagi\r\n");
fputs ($fp, "Secret: phpagi\r\n");
fputs ($fp, "Events: off\r\n\r\n");
sleep(1);
fputs ($fp, "Action: Originate\r\n");
fputs ($fp, "Channel: sip/telasip/$fromnumber\r\n");
fputs ($fp, "Callerid: $tonumber\r\n");
fputs ($fp, "Context: two-party-call\r\n");
fputs ($fp, "Extension: s\r\n");
fputs ($fp, "Priority: 1\r\n\r\n");
sleep(2);
fclose ($fp);
}
echo "$fromnumber should be ringing now.";
else :
exit();
endif;
?>
s,1,Playback(pls-wait-connect-call)
// exten => s,2,Macro(dialout-trunk,5,${CALLERIDNUM},)
// exten => s,3,Macro(outisbusy)
$fromnumber=strtolower($_REQUEST['from']);
$pos=strpos ($fromnumber,"local");
$tonumber=strtolower($_REQUEST['to']);
if ($fromnumber == null) :
exit();
endif;
if ($pos===false) :
$errno=0;
$errstr=0;
$fp = fsockopen ("localhost", 5038, &$errno, &$errstr, 20);
if (!$fp) {
echo "$errstr ($errno)
\n";
}
else {
fputs ($fp, "Action: login\r\n");
fputs ($fp, "Username: phpagi\r\n");
fputs ($fp, "Secret: phpagi\r\n");
fputs ($fp, "Events: off\r\n\r\n");
sleep(1);
fputs ($fp, "Action: Originate\r\n");
fputs ($fp, "Channel: sip/telasip/$fromnumber\r\n");
fputs ($fp, "Callerid: $tonumber\r\n");
fputs ($fp, "Context: two-party-call\r\n");
fputs ($fp, "Extension: s\r\n");
fputs ($fp, "Priority: 1\r\n\r\n");
sleep(2);
fclose ($fp);
}
echo "$fromnumber should be ringing now.";
else :
exit();
endif;
?>
Comments