网页回拨-Web CallBack

asterisk上的回拨脚本:

vi /var/lib/asterisk/agi-bin/webcall.sh

#!/bin/bash
if [ $# -ne 2 ]; then
exit;
else
CALLFROM_EXT="$1"
CALLNUM="$2"
fi
CALLTO="$CALLPREFIX$CALLNUM"

#echo Channel: Local/$CALLTO@from-internal
#echo MaxRetries: 0
#echo RetryTime: 3
#echo WaitTime: 20
#echo Context: from-internal
#echo Extension: $CALLFROM_EXT
#echo Priority: 1
#echo CallerID: /"WebCall/"/<$CALLNUM/>
#
echo Channel: Local/$CALLTO@from-internal > /etc/asterisk/$CALLTO.call
echo MaxRetries: 0 >> /etc/asterisk/$CALLTO.call
echo RetryTime: 3 >> /etc/asterisk/$CALLTO.call
echo WaitTime: 20 >> /etc/asterisk/$CALLTO.call
echo Context: from-internal >> /etc/asterisk/$CALLTO.call
echo Extension: $CALLFROM_EXT >> /etc/asterisk/$CALLTO.call
echo Priority: 1 >> /etc/asterisk/$CALLTO.call
echo CallerId: WebCall /<$CALLNUM/> >> /etc/asterisk/$CALLTO.call

chown asterisk:asterisk /etc/asterisk/$CALLTO.call
mv /etc/asterisk/$CALLTO.call /var/spool/asterisk/outgoing

网页 /var/www/html/webcall.php :

<html>
<head>
<title>Click2Dial</title>
<style type="text/css">
<!--
body{
font-size:12px!important;font-size:11px;
margin:0;
padding:0;
text-align:center;
background:#63CF63;

color:#333333;
font-family: Arial, Helvetica, sans-serif ;
}

-->

<!--
.xtop, .xbottom {display:block; background:transparent; font-size:1px;}
.xb1, .xb2, .xb3, .xb4 {display:block; overflow:hidden;background: #DFE6EF;}
.xb1, .xb2, .xb3 {height:1px;}
.xb2, .xb3, .xb4 {border-left:1px solid #0088CC; border-right:1px solid #0088CC;}
.xb1 {margin:0 5px; background:#0088CC;}
.xb2 {margin:0 3px; border-width:0 2px;}
.xb3 {margin:0 2px;}
.xb4 {height:2px; margin:0 1px;}
.xboxcontent {display:block; border:0 solid #0088CC; border-width:0 1px; padding: 4px; background: #DFE6EF;}
-->

</style>

<script language='JavaScript'>
function CloseClicked(){
window.returnValue = '';
window.close()
}

function start(){
webcall.txtphonenumber.disabled = false;
}

onload = start;
</script>
</head>
<body>
<p></p><p></p>
<?php
#--------------------------------------------------------------------------------------------
#Shouldn't need to edit anything below this point to make this script work
#--------------------------------------------------------------------------------------------
#get the phone number from the posted form
$callNumber = $_POST['txtphonenumber'];
$callerNumber= $_POST['callernumber'];

#specify the caller id for the call
$strCallerId = "Webcall". " <$callNumber>";

$length = strlen($callNumber);

//if ($length == 10 && is_numeric($strExten))
if (is_numeric($callNumber))
{
$output = shell_exec("/var/lib/asterisk/agi-bin/./webcall.sh "."$callerNumber"." "."$callNumber"."");
echo "$output";
?>
<p>
<table align="center" width="98%" height="196" border="0" bordercolor="#0f0f0f" cellpadding="3" cellspacing="0">
<tr><td valign="top">
<b class="xtop">
<b class="xb1"></b>
<b class="xb2"></b>
<b class="xb3"></b>
<b class="xb4"></b>
</b>
<div class="xboxcontent">
We are processing your call, please wait about one minutes.
If you have not received our call within one minutes, verify that your number were entered correctly and
waiting 30 seconds then try again.<p></p>
<input type=button value="Click me" id=try_button οnclick="history.go(-1)">
<p></p><br><p></p>
</div>
<b class="xbottom">
<b class="xb4"></b>
<b class="xb3"></b>
<b class="xb2"></b>
<b class="xb1"></b>
</b>
</td></tr>
</table>
</p>
<b><a href="javascript:CloseClicked()">Close Window</a></b>
<script language="JavaScript">
var time=30000;//count down 10 seconds

function CountDown(objid){
if(time<=0){
document.getElementById(objid).value='Click to Try Again';
document.getElementById(objid).disabled=false;
}else{
document.getElementById(objid).disabled = true;
document.getElementById(objid).value = (time/1000) + " sec...";
setTimeout("CountDown('" + objid + "')",1000);
}
time-=1000;
}
CountDown('try_button');
</script>


<?
}
else
{
?>
<p>
<table align="center" width="98%" border="0" bordercolor="#0f0f0f" cellpadding="3" cellspacing="0">
<tr><td>
<b class="xtop">
<b class="xb1"></b>
<b class="xb2"></b>
<b class="xb3"></b>
<b class="xb4"></b>
</b>
<div class="xboxcontent">
Enter your SIP number (e.g. 0701234567). If available, we will call you within the next two minutes.
<form name="webcall" action="<? echo $_SERVER['PHP_SELF'] ?>" method="post">
<br>
CallerNumber: <input type="text" size="20" maxlength="12" name="callernumber">
<br><br>
CallNumber: <input type="text" size="20" maxlength="12" name="txtphonenumber">
<input type="submit" value="Dial">
<br><br>
<center>
<input type="button" value="Close" οnclick="CloseClicked()">
</center>
</form>
</div>
<b class="xbottom">
<b class="xb4"></b>
<b class="xb3"></b>
<b class="xb2"></b>
<b class="xb1"></b>
</b>
</td></tr>
</table>
</p>
<?
}
?>
<br>
<!-- Footer -->
<div class="footer" style="float:right; line-height:11px">
<p align="right">
<u>This page is written by A-Lang. 2007/12/5</u>&nbsp;
</p>
</div>
<!-- Footer-->

</body>
</html>

参考: http://www.osslab.org.tw/VoIP/IP_PBX/軟體式_IP_PBX/Asterisk/Tips/網頁回撥-Web_CallBack

Powered by Zoundry Raven

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值