1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /** * 小程序换取openid * * @param code 识别得到用户id必须的一个值 得到网页授权凭证和用户id * @return */ @RequestMapping ( "/get/openid" ) public @ResponseBody Object GetOpenid(String 你的小程序APPID, String code, String 你的小程序秘钥) { if (code == null || code.length() == 0 ) { throw new CustomException( "code不能为空!" ); } return GetOpenIDUtil.oauth2GetOpenid(appid, code, appsecret); }<br>这个code的话我这个一般是前端生成比较好,所以你后台的话,把接口给前端,让他那边传个code, |