最近做微信开发,遇到一个问题。我使用微信的测试账号进行开发。设置了一个菜单项跳转到微信的网页授权,菜单json内容如下
{
"button": [
{
"type": "view",
"name": "Admin",
"url": "http://edu.nasuf.cn/admin/"
},
{
"type": "view",
"name": "Teacher",
"url": "http://edu.nasuf.cn/teacher/"
},
{
"type": "view",
"name": "Student",
"url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=http%3a%2f%2fedu.nasuf.cn%2fstudent%2f&response_type=code&scope=snsapi_userinfo&state=s"
}
]
}
但是在测试的时候发现,点击菜单‘Student'后,页面并没有跳转到授权页面,而是直接跳转到redirect_rui所配置的界面了。
后来我在页面上添加了一个a标签,如下:
<a href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=http%3a%2f%2fedu.nasuf.cn%2fstudent%2f&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect">测试网页授权</a>
依然没有弹出授权页面,直接跳转到redirect_uri页面;
我又换成后台response跳转,测试如下:
@RequestMapping(value = "/webAuth", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> webAuth(HttpServletRequest request, HttpServletResponse response) {
try {
logger.debug("redirect to wechat web auth page...");
response.sendRedirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa6060fbdcbb1611c&redirect_uri=http%3a%2f%2fedu.nasuf.cn%2fstudent%2f&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
还是同样的结果,没有任何变化,并没有跳转授权页面。
我已经在微信公众号配置中配置过了授权域名为'edu.nasuf.cn',并使用微信web开发者工具进行测试,没有任何问题,可以跳转到授权页面的。但是为什么在微信手机端测试就没有效果呢?请问可能是什么原因啊?
跪谢大家!!!
请问楼主怎么解决的?我也遇到同样的问题