前端 - 在开发网页授权获取用户基本信息时code是null
PHP中文网
PHP中文网 2017-04-17 11:24:52
0
0
677

在开发网页授权获取用户基本信息时,第一步的获取code时获取到的是null 网页授权获取用户基本信息,url地址是:https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx7d24a6105455ffae&redirect_uri=http%3A%2F%2Fmobileotc.999.com.cn%2Fstore%21loginCode.action&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect,请问这是什么原因?

代表如下:

    String url = Constants.DOMAIN+"/store!loginCode.action";
    StringBuffer sb = new StringBuffer("https://open.weixin.qq.com/connect/oauth2/authorize?");
    sb.append("appid=").append(Constants.APPID);
    try {
        sb.append("&redirect_uri=").append(URLEncoder.encode(url, "utf-8"));
        sb.append("&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
        log.info("loginWeiXin url:"+sb.toString());
        response.sendRedirect(sb.toString());
    } catch (IOException e) {
        log.info(e.getMessage());

}

获取代表如下:

    String code= request.getParameter("code");
    log.info("loginCode:"+code);

打印出来的信息是loginCode:null

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!