QQAP_交互查询-API模式说明

作者: 平淡人生 分类: QQAP_中级,WXAP_中级 发布时间: 2021-11-13 10:01

1.导入最新的模版或者手动新建指定的字段
PS: 新增 字段信息如下
主表
APIURL 文本字段(API网站)
JXDX  文本字段(JSON 返回解析对象)
TJMS 整数字段 (访问模式 0:GET  , 1: POST)
明细
AI 字段下拉选择新增  GET 选项
DXMC 文本字段 (JSON解析对象名称)
POST 文本字段 (POST)
2.点击交互查询下方的按钮恢复使用最新的默认语句(也可手工添加字段)
把新增的字段引入SQL语句
3.打开API模式

4.新建API交互查询表单
例1:对接快递100进行查询快递

PS:
APIURL  http://www.kuaidi100.com/query?type={{.p1}}&postid={{.p2}}
其中的{{.p1}},{{.p2}}来源于下级交互输入内容
demo
http://www.kuaidi100.com/query?type=yunda&postid=3101775486667
解析方法:
API结果如下:

  1. {
  2. “message”: “ok”,
  3. “nu”: “3101775486667”,
  4. “ischeck”: “0”,
  5. “condition”: “00”,
  6. “com”: “yunda”,
  7. “status”: “200”,
  8. “state”: “5”,
  9. “data”: [{
  10.   “time”: “2018-05-24 08:40:05”,
  11.   “ftime”: “2018-05-24 08:40:05”,
  12.   “context”: “[河北秦皇岛公司]进行快件扫描,发往:河北秦皇岛公司经济技术开发区分部”,
  13.   “location”: null
  14. }, {
  15.   “time”: “2018-05-23 16:44:37”,
  16.   “ftime”: “2018-05-23 16:44:37”,
  17.   “context”: “[河北秦皇岛公司]到达目的地网点,快件很快进行派送”,
  18.   “location”: null
  19. }, {
  20.   “time”: “2018-05-23 16:44:25”,
  21.   “ftime”: “2018-05-23 16:44:25”,
  22.   “context”: “[河北秦皇岛公司]到达目的地网点,快件很快进行派送”,
  23.   “location”: null
  24. }, {
  25.   “time”: “2018-05-23 07:43:42”,
  26.   “ftime”: “2018-05-23 07:43:42”,
  27.   “context”: “[北京分拨中心]从站点发出,本次转运目的地:河北秦皇岛公司”,
  28.   “location”: null
  29. }, {
  30.   “time”: “2018-05-23 07:05:27”,
  31.   “ftime”: “2018-05-23 07:05:27”,
  32.   “context”: “[北京分拨中心]在分拨中心进行卸车扫描”,
  33.   “location”: null
  34. }, {
  35.   “time”: “2018-05-22 01:53:04”,
  36.   “ftime”: “2018-05-22 01:53:04”,
  37.   “context”: “[重庆分拨中心]进行装车扫描,发往:北京分拨中心”,
  38.   “location”: null
  39. }, {
  40.   “time”: “2018-05-22 01:48:36”,
  41.   “ftime”: “2018-05-22 01:48:36”,
  42.   “context”: “[重庆分拨中心]在分拨中心进行称重扫描”,
  43.   “location”: null
  44. }, {
  45.   “time”: “2018-05-22 00:06:07”,
  46.   “ftime”: “2018-05-22 00:06:07”,
  47.   “context”: “[重庆渝中区杨家坪公司]进行揽件扫描”,
  48.   “location”: null
  49. }, {
  50.   “time”: “2018-05-21 21:37:17”,
  51.   “ftime”: “2018-05-21 21:37:17”,
  52.   “context”: “[重庆渝中区杨家坪公司]进行下级地点扫描,发往:北京分拨中心”,
  53.   “location”: null
  54. }, {
  55.   “time”: “2018-05-21 20:16:09”,
  56.   “ftime”: “2018-05-21 20:16:09”,
  57.   “context”: “[重庆渝中区杨家坪公司]进行揽件扫描”,
  58.   “location”: null
  59. }]
  60. }

复制代码

例如:这里需要取出  
nu(运单号码)  
status(状态)
和data数组明细内的 context和time
JSON解析对象名称:”nu+运单号码|status+状态|data[time+时间,context+详情]“
PS:  其中| 为多个对象分隔符,[]为数组对象(数组内对象使用半角逗号分割),+后面为返回数据时的别名
返回结果如下:



例2:对接企业微信发送消息为企业微信用户

PS:发送企业微信首先需要获取AccessToken
这里下级参数 API URL 内填写https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=id&corpsecret=secrect

 

  • 参数说明

参数           必须     说明
corpid         是      企业Id
corpsecret   是      管理组的凭证密钥
AI 字段选择GET

根据微信开发文档得知返回数据格式 :

{   “access_token”: “accesstoken000001”,   “expires_in”: 7200}
这里需要取出 access_token 所以 返回对象字段 填写access_token
发送消息API URL 地址为:
https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={{.p1_ai0}}
{{.p1_ai0}} 为下级的access_token返回结果
POST 数据格式为:

{“touser”: “{{.p1}}”,”msgtype”: “text”,”agentid”: 7,”text”: {“content”: “{{.p2}}”},”safe”:0}

其中的{{.p1}},{{.p2}}来源于下级交互输入内容

3.4.8 更新1.APIURL 支持变量({{来源QQ}}, {{信息内容}}, {{来源群}},{{讨论组}}, {{模版名称}}, {{年}}, {{月}}, {{日}},{{时}} ,{{分}}, {{秒}}, {{随机}})
2.POST 支持系统变量({{姓名}},{{账号}},{{部门}},{{手机号}},{{邮箱}},{{性别}},{{职位}},{{来源QQ}}, {{信息内容}}, {{来源群}},{{讨论组}}, {{模版名称}}, {{年}}, {{月}}, {{日}},{{时}} ,{{分}}, {{秒}}, {{随机}})

PS:解析说明JOSN

  1. {
  2.         “test1”: “Hello World!”,
  3.         “test2”: {
  4.                 “child1”: “值1”,
  5.                 “child2”: “值2”
  6.         },
  7.         “array”: [{
  8.                 “app1”: “值a”,
  9.                 “app2”: “值b”
  10.         }, {
  11.                 “app1”: “值c”,
  12.                 “app2”: “值d”
  13.         }],
  14.         “data”: {
  15.                 “city”: {
  16.                         “cityId”: “值3”,
  17.                         “counname”: “值4”,
  18.                         “pname”: “值5”
  19.                 },
  20.                 “condition”: {
  21.                         “cond”: “值6”,
  22.                         “windDir”: “值7”,
  23.                         “windLevel”: “值8”
  24.                 }
  25.         },
  26.         “date”: {
  27.                 “shidu”: “22%”,
  28.                 “wendu”: “值9”,
  29.                 “ganmao”: “值10”,
  30.                 “forecast”: [{
  31.                                 “date”: “22”,
  32.                                 “ymd”: “2018-09-22”,
  33.                                 “week”: “星期六”
  34.                         },
  35.                         {
  36.                                 “date”: “23”,
  37.                                 “ymd”: “2018-09-23”,
  38.                                 “week”: “星期日”
  39.                         }
  40.                 ]
  41.         }
  42. }

解析说明:

1.test1 解析结果 “Hello World!”
2.test1+名称:解析结果 “名称:Hello World!”
3.test2{child1} 解析结果 “值1”
4.test2{child2+名称:} 解析结果 “名称:值2”
5.data{city{cityId}}解析结果 “值3”
6.data{city{counname+结果:}}解析结果 “结果:值4”
7.array[app1+名称:,app2+地址:]
解析结果“名称:值a
地址:值b
名称:值c
地址:值d”
8.array[app1+名称:,app2+地址:]1
解析结果“名称:值a
地址:值b”
9.date{forecast[ymd+日期:,week]}
解析结果“日期:2018-09-22
星期六
日期:2018-09-23
星期日”
10.9.date{forecast[ymd+日期:,week]1}
解析结果“日期:2018-09-22
星期六”

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

一条评论