企业微信会话缓存,由于会话种类多达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. 会话只能拉取三天以内的,可以做个定时任务每天多次拉取