php微信公众号开发之发送模板消息

/ 0评 / 0

第一步,先进行授权登录,获取到用户的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>";
   }
}

发表回复

您的电子邮箱地址不会被公开。