企业微信会话缓存

本文围绕企业微信会话缓存开发展开,因会话种类多达23种,代码复杂。作者分享了踩坑经验,包括资源拉取需多次判断、语音格式转换、私钥处理、资源拉取失败处理、Finance包要求以及会话拉取时间限制等,并给出相应解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

企业微信会话缓存,由于会话种类多达23种,所以需要不同判断.代码比较复杂.
其中我踩坑的地方有

  1. 拉取的文件,图片等资源,一次拉取为512K,需要判断,多次拉取
  2. 语音是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();
      }
  }
  1. 私钥需要将其换成一行,不然容易报错.如下图这样的,我的是会报错.所以把他展直之后就不报错了

像这样的
4. 资源拉取可能会失败.可以加上判断多次拉取
5. Finance的包必须是tencent.wework
6. 会话只能拉取三天以内的,可以做个定时任务每天多次拉取

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值