企业微信会话缓存,由于会话种类多达23种,所以需要不同判断.代码比较复杂.
其中我踩坑的地方有
- 拉取的文件,图片等资源,一次拉取为512K,需要判断,多次拉取
- 语音是arm格式,前端展示MP3格式比较轻松,所以可以进行转换,下面是转换的代码
/**
* @return void
* @Author liqing36
* @Description //TODO arm语音转map3格式
* @Date 16:57 2020/8/25
* @Param [sourcePath, targetPath]
**/
public static void changeToMp3(String sourcePath, String targetPath) {
File source = new File(sourcePath);
File target = new File(targetPath);
AudioAttributes audio = new AudioAttributes();
Encoder encoder = new Encoder();
audio.setCodec("libmp3lame");
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
try {
encoder.encode(source, target, attrs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InputFormatException e) {
e.printStackTrace();
} catch (EncoderException e) {
e.printStackTrace();
}
}
- 私钥需要将其换成一行,不然容易报错.如下图这样的,我的是会报错.所以把他展直之后就不报错了

4. 资源拉取可能会失败.可以加上判断多次拉取
5. Finance的包必须是tencent.wework
6. 会话只能拉取三天以内的,可以做个定时任务每天多次拉取
本文围绕企业微信会话缓存开发展开,因会话种类多达23种,代码复杂。作者分享了踩坑经验,包括资源拉取需多次判断、语音格式转换、私钥处理、资源拉取失败处理、Finance包要求以及会话拉取时间限制等,并给出相应解决办法。
1356

被折叠的 条评论
为什么被折叠?



