简要描述
企业微信第三方服务 WxCpTpUserServiceImpl,在调用 getUserId 接口时,是需要传 cropAccessToken 的,但在项目代码中,并没有进行设置 access 的地方,导致无法正常调用 API.
模块版本情况
- WxJava 模块名: weixin-java-cp
- WxJava 版本号: 4.4.0
详细描述
该接口的代码
https://github.com/Wechat-Group/WxJava/blob/develop/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java#L189
@OverridepublicStringgetUserId(Stringmobile) throwsWxErrorException {
JsonObjectjsonObject = newJsonObject();
jsonObject.addProperty("mobile", mobile);
Stringurl = mainService.getWxCpTpConfigStorage().getApiUrl(GET_USER_ID);
StringresponseContent = this.mainService.post(url, jsonObject.toString());
JsonObjecttmpJsonElement = GsonParser.parse(responseContent);
returntmpJsonElement.getAsJsonObject().get("userid").getAsString();
}使用 WxJava 中的方法来调用:
WxCpTpServicewxCpTpService = newWxCpTpServiceImpl();
wxCpTpService.setWxCpTpConfigStorage(wecomSaasDefaultConfig);
StringwecomUserId = wxCpTpService.getWxCpTpUserService().getUserId("13000000000");
WxCpUserwecomUser2 = wxCpTpService.getWxCpTpUserService().getById(wecomUserId, enterpriseCorpConfig.getCorpId());会报错误:
错误代码:41001, 错误信息:缺少access_token参数,微信原始报文:{"errcode":41001,"errmsg":"access_token missing, hint: [1661569918531331035431592]
手工调用
JsonObjectjsonObject = newJsonObject();
jsonObject.addProperty("mobile", staff.getPhoneNumber());
StringuserJson = wxCpTpService.post("https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=" + accessToken, jsonObject.toString());这样手工拼接 url 是可以成功的。
简要描述
企业微信第三方服务 WxCpTpUserServiceImpl,在调用
getUserId接口时,是需要传 cropAccessToken 的,但在项目代码中,并没有进行设置 access 的地方,导致无法正常调用 API.模块版本情况
详细描述
该接口的代码
https://github.com/Wechat-Group/WxJava/blob/develop/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpUserServiceImpl.java#L189
使用 WxJava 中的方法来调用:
会报错误:
手工调用
这样手工拼接 url 是可以成功的。