在已经获取到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"}
报这个错的兄弟们可以尝试下去掉路径的首个斜杠,文档误导人。
tx产品这么拉,还觉得自己nb也真是不容易
你好,解决了吗