第一步,先进行授权登录,获取到用户的openid,这步必不可少
// 微信授权登陆
if (!empty($appid) && !empty($appsecret)) {
if (isMobile() && isWeixin()) {
// 获取微信配置授权登陆
$NewUrl = 'https://rhxt.hnrhrj.com/wxapi/get_wechat_info.php';
$ReturnUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $appid . "&redirect_uri=" . $NewUrl . "&response_type=code&scope=snsapi_userinfo&state=rhrj&#wechat_redirect";
header("Location: $ReturnUrl");
}else{
echo "<script>alert('请在手机端微信打开');</script>";
}
}