PHP批量创建用户注册
centOS7下
1. 安装mod_xml_curl模块
1. 在源码目录下:
2. make mod_xml_curl && make mod_xml_curl-install
2. cd /usr/local/freeswitch/conf/autoload_configs/目录下的modules.conf.xml文件取消
1. <!-- <load module="mod_xml_curl"/> -->的注释
3. 为mod_xml_curl绑定网关
1. 编辑/freeswitch/conf/autoload_configs/xml_curl.conf.xml
2. 添加以下
<binding name="all configs">
<param name="gateway-url" value="http://192.168.0.103:80/callCenter/directory.php/" bindings="dialplan|configuration|directory|phrases"/>
</binding>
4. 创建一个本地的http服务上面的地址就是创建的服务器地址的directory.php文件,编辑管理用户逻辑
<?php
header("content-type:text/html;charset=utf-8");
require_once "include/common.php"; //全局引导文件
require_once 'freeSwitchEsl.php';
session_start();
//$freeswitch = new Freeswitchesl();
//$connect = $freeswitch->connect("192.168.0.126","8021","ClueCon");
$tel = $_POST['user'];
$domain = $_POST['domain'];
//查询数据库用户名
$query = $sqs_db->query("select * from fs_user WHERE username=$tel");
while($row = $sqs_db->fetch_array($query))
{
$pwd=$row["password"];
?>
<?php if($pwd){ ?>
<document type="freeswitch/xml">
<section name="directory">
<domain name="<?php echo $domain;?>">
<params>
<param name="dial-string" value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
</params>
<groups>
<group name="default">
<users>
<user id="<?php echo $tel; ?>">
<params>
<param name="password" value="<?php echo $pwd; ?>"/>
<param name="vm-password" value="<?php echo $pwd; ?>"/>
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local"/>
<variable name="accountcode" value="<?php echo $tel; ?>"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="FreeSWITCH-CN"/>
<variable name="effective_caller_id_number" value="<?php echo $tel;?>"/>
<!-- <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/> -->
<!-- <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/> -->
<variable name="callgroup" value="default"/>
<variable name="sip-force-contact" value="NDLB-connectile-dysfunction"/>
<variable name="x-powered-by" value="http://www.freeswitch.org.cn"/>
</variables>
</user>
</users>
</group>
</groups>
</domain>
</section>
</document>
<?php }else {
echo "不符合要求";
}
}?>
5. 然后再FS中执行reload mod_xml_curl
6. xml_curl debug_on命令可以开启日志
win7下配置
windows环境下模块已经安装,无需手动安装
1. 打开\conf\autoload_configs目录下的modules.conf,配置启动时自动加载mod_xml_curl模块
<load module="mod_xml_curl"/>
2. 配置\conf\autoload_configs目录下的xml_curl.xml文件,添加链接的http地址
<bindings>
<binding name="all configs">
<param name="gateway-url" value="http://192.168.0.103:80/callCenter/directory.php/" bindings="directory"/>
</binding>
</bindings>
3. php文件内容同上