Publish: September 25, 2020
Category: 编程
No Comments
FreeSwitch支持多种方式的控制配置,使用webapi方式相对其他方式命令简单,比较直观。期认证方式为HTTP Basic认证方式,也就是在发送控制命令的时候携带用户名密码即可。
如果开启了mod_curl模块,在浏览器中访问 http://your-host:8080/webapi/help 会看到如下所有命令。. Shutdown mod_commands
acl Compare an ip to an acl list mod_commands
alias [add|stickyadd] | del [|*] Alias mod_commands
amr_debug Set AMR Debug mod_amr
av debug [on|off] | show AV general commands mod_av
banner Return the system banner mod_commands
bg_system Execute a system command in the background mod_commands
bgapi [ ] Execute an api command in a thread mod_commands
break [all] uuid_break mod_commands
cdr_csv parameters cdr_csv controls mod_cdr_csv
chat ||||[] chat mod_dptools
coalesce [^^],,...
以上只列举了一部分。
使用php的curl方式构建请求方法:function httpCurlGet($url){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "$url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 3,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic xxxxxxxx="
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
Authorization 这里要改成自己的用户名:密码拼接的base64编码。密码通常会配置在 "autoload_configs/xml_rpc.conf.xml" 中和
以为多人会议为例子,想对会议成员禁听,禁止听到会议内容。查看命令表是这样表述的:
conference 命令下deaf
如果是在fs_cli命令行中可以直接这样操作:#对会议3001中的1001禁听
conference 3001 deaf 1001
#对会议3001中所有用户禁听
conference 3001 deaf all
如果使用webapi方式只需要做简单转换即可:%20是空格的url编码,如果语言不支持则直接使用其替换即可。#对会议3001中的1001禁听
http://yourhost:8080/webapi/conference?3001%20deaf%201001
#对会议3001中的中所有用户禁听
http://yourhost:8080/webapi/conference?3001%20deaf%20all
以上就是一个完整的控制功能
Tags: none
Related Posts:
[尚无相关文章]