前言:
官方参考连接:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html
1、用户同意授权,获取code
public void getCode(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//appid是公众号的appid
String redirect_uri=Param.local_url+"wx/openid";
String url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri="
+ URLEncoder.encode(redirect_uri, "GBK")
+ "&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=