2021-04-04 03:38| 发布者: | 查看: |
?php function doCurl($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); $info = json_decode($res,true); curl_close($ch); return $info; } $appid= 微信公众号appid $secret= 微信公众号秘钥 // openid得到 $urlTmp = sns/oauth2/access_token?appid=$appid secret=$secret code= .$_GET['code']. grant_type=authorization_code $res = doCurl($urlTmp); $ssWxid = $res['openid']; // access_token得到 $url_get = cgi-bin/token?grant_type=client_credential appid=$appid secret=$secret $resToken = doCurl($url_get); $access_token = $resToken['access_token']; // 分辨是不是早已关心微信公众号 $subscribe_msg = 'cgi-?access_token='.$access_token.' openid='.$ssWxid; $subscribe = doCurl($subscribe_msg); $zyxx = $subscribe['subscribe']; ? script type= text/javascript function redirectToHttps() { ?php if ($zyxx !== 1) { ? // 未关心时,自动跳转到关心网页页面 window.location = mp/profile_ext?action=home __biz=MjM5CTEwNjI0OQ== scene=124#wechat_redirect ?php } else { ? // 早已关心时,自动跳转到业务流程网页页面 ?php } ? } /script body onload= redirectToHttps() /body /html