//注入依赖
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
<version>4.3.0</version>
</dependency>
//添加配置
wx:
miniapp:
appid: 1523554
secret: 123456
msgDataFormat: JSON
//开始使用
private final WxMaService wxMaService;
@Override
public Response getWeChatUserByCode(String code) {
try {
return SingleResponse.of(wxMaService.getUserService().getSessionInfo(code));
} catch (WxErrorException e) {
e.printStackTrace();
throw new BizException(ErrorCode.FAILED_GET_OPENID, ErrorCode.FAILED_GET_OPENID.getErrDesc());
}
}
获取微信OpenID
于 2022-04-24 21:03:24 首次发布