微信获取用户openid

时间:2019-01-07 17:30:48   收藏:0   阅读:153
   @GetMapping({"/getOpenId"})
    public void getOpenId(HttpServletResponse response)
    {
        try
        {
            StringBuffer sb = new StringBuffer();
            try
            {
                sb.append("https://open.weixin.qq.com/connect/oauth2/authorize?appid=***************&redirect_uri=").append(URLEncoder.encode("http://********授权地址*******/wechat/login", "utf-8"));
                sb.append("&response_type=code&scope=snsapi_userinfo&state=2#wechat_redirect");
            }
            catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
            response.sendRedirect(sb.toString());
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!