在開發(fā)網(wǎng)頁授權(quán)獲取用戶基本信息時(shí),第一步的獲取code時(shí)獲取到的是null 網(wǎng)頁授權(quán)獲取用戶基本信息,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,請(qǐng)問這是什么原因?
代表如下:
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
認(rèn)證高級(jí)PHP講師