主题
企业微信的按钮回调 3.6.2.SP4+(不包含 3.7.1Beta1)
需要在企业微信的应用中配置回调地址:
1.1. 我的企业->企业id记录下来
1.2. 应用管理>点击应用>接收消息【设置api接收】>URL 填写{gateway}/qyWechat/callback 将token和encoingAesKey 记录下来,先不点保存
1.3. 保存到minos的表中,将上面三个值更新到config_value中,查询sql
sql
select *from T_TF_CONFIG where CONFIG_KEY in ('workweixin.callback.token','workweixin.callback.encodingAESKey','workweixin.corp.id' )1
1.4. 企业微信的api接收页面点击保存,如果保存成功说明企业微信和消息中心的回调配置成功
消息中心和业务方的回调地址配置
2.1. 业务方需要在融合管控台的应用管理,消息->编辑->输入业务方提供的回调地址
业务方的回调接口格式要求: 消息中心回调业务方的回调参数介绍,
| 字段名 | 参数名 | 是否必传 |
|---|---|---|
| 用户账号 | userAccount | M |
| 点击按钮的key | eventKey | M |
| 企业微信响应的Response_code | responseCode | M |
业务方的返回参数格式
| 字段名 | 参数名 | 是否必传 | 类型 |
|---|---|---|---|
| 错误吗 0 标识成功 | errcode | M | string |
| 错误信息(消息中心会打印在日志中) | errmsg | O | string |
| 业务方返回给企业微信的更新按钮数据,是一个xml的字符串,参考企业微信的更新按钮格式 https://developer.work.weixin.qq.com/document/path/90241 可以参照下下面的demo, <ToUserName> <FromUserName><CreateTime> 这三个标签不用处理,消息中心会自动拼接上 | data | M | string |
注意业务方返回
json
{
"errcode":"0",
"data":"<xml/> <MsgType>update_button</MsgType> <Button><ReplaceName>ReplaceName</ReplaceName> </Button></xml>"
}1
2
3
4
2
3
4
java示例代码
java
/**
*
* 回调请求
* @date 2024/2/20 14:22
* @author jszhang@wisedu
* @version 1.0
**/
@Data
public class CallbackRequest {
/**
* 用户账号
*/
private String userAccount;
/**f
* 用户点击按钮的key
*/
private String eventKey;
/**
* 企业微信回调返回的responseCode,调用企业微信更新接口可以直接使用
*/
private String responseCode;
}
@RestController
@Slf4j
@RequestMapping("/admin")
public class TestController {
@RequestMapping("/testCb")
public CallbackResponse testCb(@RequestBody CallbackRequest callbackRequest) {
System.out.println(JSONObject.toJSONString(callbackRequest));
CallbackResponse callbackResponse = new CallbackResponse();
callbackResponse.setErrcode("0");
callbackResponse.setData(" <xml> <MsgType>update_button</MsgType>\n" +
" <Button>\n" +
" <ReplaceName>ReplaceName</ReplaceName>\n" +
" </Button></xml>");
return callbackResponse;
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

