龙空技术网

freeswitch的mod_curl模块

求真得真 38

前言:

目前兄弟们对“centos7openvswitch”大致比较讲究,看官们都想要学习一些“centos7openvswitch”的相关资讯。那么小编在网摘上收集了一些有关“centos7openvswitch””的相关文章,希望看官们能喜欢,姐妹们一起来学习一下吧!

概述

有时候,我们需要在呼叫的过程中,或过程后调用web api接口。

freeswitch的mod_curl模块可以很方便的实现web api的接口调用。

mod_curl模块默认不安装,需要进入模块目录自行编译安装,并配置modules.conf.xml文件在fs启动时加载模块。

<load module="mod_curl"/>
环境

centos:CentOS 7

freeswitch:v1.10.7

GCC:4.8.5

API接口

api接口格式。

curl url [headers|json|content-type <mime-type>|connect-timeout <seconds>|timeout <seconds>] [get|head|post|delete|put [data]]
APP接口

app接口格式。

<action application="curl" data="url [headers|json] [get|head|post [url_encode_data]]"/>
测试实例
freeswitch@localhost.localdomain> curl  content-type application/json;charset=utf-8 connect-timeout 1 timeout 1 post '{"test":"1234","duration":15}'2022-11-09 16:00:54.288442 [DEBUG] mod_curl.c:200 method: post, url: , content-type: application/json;charset=utf-82022-11-09 16:00:54.288442 [DEBUG] mod_curl.c:252 Post data: {"test":"1234","duration":15}{"status":0}freeswitch@localhost.localdomain> curl  content-type application/json;charset=utf-8 connect-timeout 1 timeout 1 json post '{"test":"1234","duration":15}'2022-11-09 16:02:31.008475 [DEBUG] mod_curl.c:200 method: post, url: , content-type: application/json;charset=utf-82022-11-09 16:02:31.008475 [DEBUG] mod_curl.c:252 Post data: {"test":"1234","duration":15}{"status_code":"200","body":"{\"status\":0}","version":"HTTP/1.0","phrase":"OK","headers":[{"key":"Server","value":"BaseHTTP/0.6 Python/3.10.7"},{"key":"Date","value":"Wed, 09 Nov 2022 08:02:31 GMT"},{"key":"Content-Type","value":"application/json;charset=utf-8"}]}

其中第二条带了“json”参数,返回值的code、header和消息体统一变更为json格式。

总结

简单的web api接口调用可以直接使用mod_curl模块接口。

如果需要在定时任务中调用curl接口,需要注意什么地方。

空空如常

求真得真

标签: #centos7openvswitch