网页回拨源码

来源:互联网 发布:电子商务网络平台创业 编辑:程序博客网 时间:2024/04/29 19:12

ASTERISK+LINUX+PHP 的WebCall, 网页回拨源码

801 响起再拨打到 1000

$strChannel ="SIP/801";

$strExten =1000;

 把下列代码保存为.php文件,放于www/html 下  
修改下面$strUser ; $strSecret ; $strChannel ; $strExten ; 参数
$strUser = "admin"; $strSecret = "amp111";为 ami接口帐号密码
$strChannel 为内部分机号码,$strExten回拨号码

<?
#------------------------------------------------------------------------------------------ 
#edit the below variable values to reflect your system/information 
#------------------------------------------------------------------------------------------
#specify the name/ip address of your asterisk box 
#if your are hosting this page on your asterisk box, then you can use 
#127.0.0.1 as the host IP.? Otherwise, you will need to edit the following 
#line in manager.conf, under the Admin user section: 
#permit=127.0.0.1/255.255.255.0 
#change to: 
#permit=127.0.0.1/255.255.255.0,xxx.xxx.xxx.xxx ;(the ip address of the server this page is running on) 
$strHost = "127.0.0.1";
#specify the username you want to login with (these users are defined in /etc/asterisk/manager.conf) 
#this user is the default AAH AMP user; you shouldn't need to change, if you're using AAH. 
$strUser = "admin";
#specify the password for the above user 
$strSecret = "123456";
#specify the channel (extension) you want to receive the call requests with 
#e.g. SIP/XXX, IAX2/XXXX, ZAP/XXXX, etc
$strChannel = "SIP/{$_POST['sip']}";
#specify the context to make the outgoing call from.? By default, AAH uses from-internal 
#Using from-internal will make you outgoing dialing rules apply 
$strContext = "from-internal";
#specify the amount of time you want to try calling the specified channel before hangin up 
$strWaitTime = "30";
#specify the priority you wish to place on making this call 
$strPriority = "1";
#specify the maximum amount of retries 
$strMaxRetry = "2";
#-------------------------------------------------------------------------------------------- 
#Shouldn't need to edit anything below this point to make this script work 
#-------------------------------------------------------------------------------------------- 
#get the phone number from the posted form 
$strExten =$_POST['callid'];
#specify the caller id for the call 
$strCallerId = "Web Call Test <$strExten>";
$oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Connection to host failed"); 
fputs($oSocket, "Action: login\r\n"); 
fputs($oSocket, "Events: off\r\n"); 
fputs($oSocket, "Username: $strUser\r\n"); 
fputs($oSocket, "Secret: $strSecret\r\n\r\n"); 
fputs($oSocket, "Action: originate\r\n"); 
fputs($oSocket, "Channel: $strChannel\r\n"); 
fputs($oSocket, "WaitTime: $strWaitTime\r\n"); 
fputs($oSocket, "CallerId: $strCallerId\r\n"); 
fputs($oSocket, "Exten: 9$strExten\r\n"); 
fputs($oSocket, "Context: $strContext\r\n"); 
fputs($oSocket, "Priority: $strPriority\r\n\r\n"); 
fputs($oSocket, "Action: Logoff\r\n\r\n"); 
fclose($oSocket);
echo 'Call ...';
echo $strChannel
?>




另外写一个php页面 代码如下
用post方法将 callid和sip 2个参数传到callback页面


<form action="2.php" method="post">
Your number <input type="text" name="callid" />
SIP <input type="text" name="sip" />
We will call this number back <input type="submit" name="submit" value="Call back" />
</form>

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 挖耳朵挖破了怎么办 挖耳朵皮挖破了耳鸣怎么办 北京自考证丢啦怎么办 不服检察院的答复函该怎么办 检察院控申答复函不复怎么办 在看守所里疯了怎么办 第一次吸毒拘留五天第二次会怎么办 被派出所拘留15天怎么办 老公从拘留所出来聪明老婆怎么办 中信信用卡忘记还款了怎么办 监狱的犯人病了怎么办 判缓期间在行政拘留怎么办 法院拘留15天工作怎么办 高血压签定了无期限合同怎么办 法院司法拘留找不到人怎么办 c1骑摩托车要拘留怎么办 欠钱的找不到人怎么办 治安拘留人跑了怎么办 行政拘留拘留所不收应该怎么办 在看守所被打了怎么办 取保候审超过12个月怎么办 拘留20天还没有判刑怎么办 被打了没有证据怎么办 拘留37天后没有放人怎么办 强制执行执行的财产不够怎么办 收到公安局拘留通知家属应该怎么办 对方不出谅解书怎么办 寻衅滋事没抓的 怎么办 公务员政审父母拘留过怎么办 我参与了网赌怎么办 亲人出车祸去世家属怎么办 车牌换了原保险怎么办 北京车牌夫妻变更车险怎么办 赌博拘留15天不交罚款怎么办 给人打了不赔钱怎么办 打了人对方讹钱怎么办 换车了原来的etc怎么办 换异地车牌了etc怎么办 被执行人拘留15天后不还钱怎么办 被执行人拘留后还是不还钱怎么办 摩托车套牌被交警扣了怎么办