if(!isset($_GET['code'])) {
// print_r($_SERVER);
$redurl = 'https://zhongyehuanbao.cn';
//$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url = self::CODEURL 。 "appid=".self::APPID."&redirect_uri={$redurl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
// 构建跳转地址 跳转
header("位置:{$url}");
} 别的 {
$openidurl = self::OPENIDURL."appid=".self::APPID."&secret=".self::SECRET."&code=".$_GET['code']."grant_type=client_cledentail";
//授权码
$data = file_get_contents($openidurl);
$arr = json_decode($data,true);
//调用接口获取openid
$_SESSION['openid'] = $arr['openid'];
返回 $_SESSION['openid'];
}