第三方开放平台,调用获取令牌时返回40066, invalid url rid ?
发布于 4 年前 作者 na11 9992 次浏览 来自 官方Issues

在已经获取到component_verify_ticket的情况下,按照如下文档调用获取令牌的服务

https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/api/component_access_token.html

调用服务的代码如下:

public ComponentTokenInfo getComponentAccessToken(String appId, String appSecret, String verifyTicket) {
  var requestMap = Map.of("component_appid", appId,  "component_appsecret", appSecret, "component_verify_ticket", verifyTicket);
  try {
    var requestString = mapper.writeValueAsString(requestMap);
    var body = RequestBody.create(requestString, MediaType.parse("application/json"));
    var request = new Request.Builder().url(WECHAT_URL + "component_access_token").post(body).build();
    var response = client.newCall(request).execute();
    var responseString = response.body().string();
    return mapper.readValue(responseString, ComponentTokenInfo.class);
  } catch (IOException e) {
    logger.error("error in getting component access token: ", e);
    throw new RuntimeException(e);
  }
}

{“errcode”:40066,“errmsg”:“invalid url rid: 5f9623b0-3a5e636c-481a8ee8”}

回到顶部