原来正常。
更换新的微信公众号(服务号) appid 后
一直跳转加载中。
Step1:
定位到是这里的问题
@session_start(); if (!isset($_SESSION['weixin-openid'])) { echo ' <script type="text/javascript"> alert(6789) location.replace("https://open.weixin.qq.com/connect/oauth2/authorize?appid='. $appid .'&redirect_uri=https%3A%2F%2F"+ location.host +"%2Fwxpay%2F***pay%2Fredirect_uri***&response_type=code&scope=snsapi_base&state='. (isset($_GET['outTradeNo']) ? urlencode(base64_encode(json_encode([ 'outTradeNo' => $_GET['outTradeNo'], ], true))):'123') .'#wechat_redirect") </script> '; die; }
很有可能是这里的 secret 参数不对
@session_start(); $_SESSION['weixin-openid'] = json_decode(file_get_contents('https://api.weixin.qq.com/sns/oauth2/access_token?appid='. $appid .'&secret=6****a&code='. $_GET['code'] .'&grant_type=authorization_code'), true)['openid'];
正解!设置并使用新的公众号的AppSecret
发生这样的错误是因为AppSecret不对,无法通过接口获取openid。所以一直跳转。
更多疑问可联系:inksci@qq.com