使用wx.request向后端发起请求获取code,报错 “请在微信客户端打开链接”,请问如何解决
本人是在微信开发者工具上进行调试的。操作流程->小程序->内嵌公众号
webview页面onload时候调用wx.request请求后端公众号获取code接口
发起的请求如下
被301重定向后url如下
返回
<!DOCTYPE html>
<html>
<head>
<meta name=“viewport” content=“width=device-width, initial-scale=1, user-scalable=0”>
</head>
<body>
<script type=“text/javascript”>
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf(‘micromessenger’) != -1;
var isAndroid = ua.indexOf(‘android’) != -1;
var isIos = (ua.indexOf(‘iphone’) != -1) || (ua.indexOf(‘ipad’) != -1);
if (!isWeixin) {
document.head.innerHTML = ‘https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">’;
document.body.innerHTML = ‘<div class=“weui_msg”><div class=“weui_icon_area”><i class=“weui_icon_info weui_icon_msg”></i></div><div class=“weui_text_area”><h4 class=“weui_msg_title”>请在微信客户端打开链接</h4></div></div>’;
}
</script>
</body>
</html>
同求,我的网站是搭建在微擎上面的,且网站绑定了公众号。现在要开发小程序,在之前公众号网站后台写了数据返回接口。然后小程序请求后台接口,就出现了你这种情况,返回的是这样:
"<!DOCTYPE html> <html> <head> <meta name=“viewport” content=“width=device-width, initial-scale=1, user-scalable=0”> </head> <body> <script type=“text/javascript”> var ua = navigator.userAgent.toLowerCase(); var isWeixin = ua.indexOf(‘micromessenger’) != -1; var isAndroid = ua.indexOf(‘android’) != -1; var isIos = (ua.indexOf(‘iphone’) != -1) || (ua.indexOf(‘ipad’) != -1); if (!isWeixin) { document.head.innerHTML = ‘<title>抱歉,出错了</title><meta charset=“utf-8”><meta name=“viewport” content=“width=device-width, initial-scale=1, user-scalable=0”><link rel=“stylesheet” type=“text/css” href=“https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css”>’; document.body.innerHTML = ‘<div class=“weui_msg”><div class=“weui_icon_area”><i class=“weui_icon_info weui_icon_msg”></i></div><div class=“weui_text_area”><h4 class=“weui_msg_title”>请在微信客户端打开链接</h4></div></div>’; } </script> </body> </html> "
请问你解决了吗?