Skip to content

WxMaJsapiServiceImpl 里面的getCardApiTicket方法返回值有bug #1415

Closed
@Hmilyhyun

Description

@Hmilyhyun

简要描述

WxMaJsapiServiceImpl 里面的getCardApiTicket方法返回值有bug

模块版本情况

  • WxJava 模块名: cn.binarywang.wx.miniapp.api.impl.WxMaJsapiServiceImpl
  • WxJava 版本号:3.60

详细描述

下面的代码最后return那一行,一顿操作更新了cardApiTicket,最后返回了jsApiTicket

另外,我发现小程序文档里好像没有cardApiTicket和jsApiTicket的概念,代码中用的获取链接也是公众号的获取链接,建议还是删掉这两个东西…………

@Override
public String getCardApiTicket(boolean forceRefresh) throws WxErrorException {
  Lock lock = this.wxMaService.getWxMaConfig().getCardApiTicketLock();
  try {
    lock.lock();
    if (forceRefresh) {
      this.wxMaService.getWxMaConfig().expireCardApiTicket();
    }

    if (this.wxMaService.getWxMaConfig().isCardApiTicketExpired()) {
      String responseContent = this.wxMaService.get(GET_JSAPI_TICKET_URL + "?type=wx_card", null);
      JsonElement tmpJsonElement = JSON_PARSER.parse(responseContent);
      JsonObject tmpJsonObject = tmpJsonElement.getAsJsonObject();
      String jsapiTicket = tmpJsonObject.get("ticket").getAsString();
      int expiresInSeconds = tmpJsonObject.get("expires_in").getAsInt();
      this.wxMaService.getWxMaConfig().updateCardApiTicket(jsapiTicket, expiresInSeconds);
    }
  } finally {
    lock.unlock();
  }
  return this.wxMaService.getWxMaConfig().getJsapiTicket();
}

日志

没有

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions