本文共 2438 字,大约阅读时间需要 8 分钟。
FreeSwitch 支持将话单写入远程的 HTTP 服务器,在哪里你可以使用任何喜欢的编程语言处理话单以及写入任何可能的数据库。有三个模块可以实现他:mod_xml_cdr、mod_json_cdr 以及 mod_format_cdr。前两者分别产生 xml 和 json 格式,最后一个模块则可配置产生 XML 或 JSON 格式。
使用 mod_xml_curl为例:第一步: 在C:\Program
Files\FreeSWITCH\conf\autoload_configs\modules.conf.xml中释放<load module="mod_xml_curl"/>
的注释。 第二步:② C:\Program Files\FreeSWITCH\conf\autoload_configs\xml_curl.conf.xml 中添加 中的value指向你的 HTTP 服务器地址。
第三步:创建并开启HTTP服务
//连接FS服务connectFSAndSubscibeFSEvent();ExecutorService pool = Executors.newCachedThreadPool();server = HttpServer.create(new InetSocketAddress(8080),10);server.createContext("/fsapi/", new DirectoryHandler());//可以通过设置一个线程组由线程来决定执行的过程server.setExecutor(pool);server.start();System.out.println("server started:");
第四步:号码验证
/** * @author cyq *号码注册认证 */ class DirectoryHandler implements HttpHandler{ @Override public void handle(HttpExchange exc) throws IOException { //String uri=exc.getRequestURI().toString(); //获得输入流 BufferedReader reader=new BufferedReader(new InputStreamReader(exc.getRequestBody())); //用于存储请求信息 请求参数 String valueString = null; StringBuilder sbf=new StringBuilder(); while ((valueString=reader.readLine())!=null){ sbf.append(valueString); } String param=sbf.toString(); //System.out.println(param); String[] str_= param.split("&"); @SuppressWarnings("unused") String section=null; String req_key = null; String req_user = null; String req_domain = null; @SuppressWarnings("unused") String req_ip = null; String req_callout = null; String req_pswd = "1234"; for(int i=0;i" + " "+ " " + " " + ""; }else{ responseMessage= ""+ " " + " "+ ""+ " " + "" + " "+ ""+ " "+ ""+ " "+ ""+ " "+ " "+ " " + "" + " "+ ""+ " " + " " + " " + " " + " "+ " "+ " "+ " "+ " "+ " "+ " " + " "; } //回应信息 exc.sendResponseHeaders(HttpURLConnection.HTTP_OK, responseMessage.getBytes().length); OutputStream out = exc.getResponseBody(); out.write(responseMessage.getBytes()); out.flush(); exc.close(); } }" + " " + "
无意中发现了一个巨牛的人工智能教程,忍不住分享一下给大家。教程不仅是零基础,通俗易懂,而且非常风趣幽默,像看小说一样!觉得太牛了,所以分享给大家。可以跳转到教程。
转载地址:http://xwmgb.baihongyu.com/