微信登录之JAVA工具类
首先是添加pom 依赖
<!--微信--> <dependency> <groupId>com.github.binarywang</groupId> <artifactId>weixin-java-miniapp</artifactId> <version>3.3.0</version> </dependency> <!--微信支付--> <dependency> <groupId>com.github.binarywang</groupId> <artifactId>weixin-java-pay</artifactId> <version>3.3.0</version> </dependency>
我这里是引用在小程序的项目,其他项目请参考我之前 的文章:https://www.sxpcwlkj.comindex.php/2020/11/12/038/
今天我记录,客户端(小程序)获取code换取一下参数
WxMaJscode2SessionResult(sessionKey=9n2=====bXBrYA==, openid=of76=====LZ1E, unionid=null)
备注:unionid 是微信开发者管理员才会有,普通用户只有openid
首先是配置: WxProperties
这个具体配置方法看文章:https://www.sxpcwlkj.comindex.php/2020/11/12/038/
@Resource private WxMaService wxService; //code 是客户端传入controller的
WxMaJscode2SessionResult result = this.wxService.getUserService().getSessionInfo(code); 结果:
{sessionKey:"", openid:"", unionid:""}