From d6c15f0c426498bd60c976c83999f11b3f0e60fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D?= <邮箱> Date: Mon, 31 Jul 2023 15:04:12 +0800 Subject: [PATCH] test --- mobile/testsc2.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mobile/testsc2.php b/mobile/testsc2.php index 8e52176..f98f0c0 100644 --- a/mobile/testsc2.php +++ b/mobile/testsc2.php @@ -11,14 +11,14 @@ $auth_url = 'https://open.weixin.qq.com/connect/oauth2/authorize' . '?appid=' . urlencode($appid) . '&redirect_uri=' . urlencode($redirect_uri) . '&response_type=code' - . '&scope=snsapi_base' // snsapi_base 只获取openid,snsapi_userinfo 获取用户信息 + . '&scope=snsapi_userinfo' // snsapi_base 只获取openid,snsapi_userinfo 获取用户信息 . '&state=STATE'; // wechat_redirect // 如果用户已经授权,则重定向到回调URL,并获取用户的openid -// if (isset($_GET['code'])) { -// $code = $_GET['code']; +if (isset($_GET['code'])) { + $code = $_GET['code']; - $code = '100010'; + // $code = '100010'; // 构造获取access_token的URL $token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token' @@ -58,9 +58,9 @@ $auth_url = 'https://open.weixin.qq.com/connect/oauth2/authorize' // // 在这里处理获取到的openid // echo $openid; -// } else { -// // 如果没有授权,则重定向到授权页面 -// header('Location: ' . $auth_url); -// exit(); -// } +} else { + // 如果没有授权,则重定向到授权页面 + header('Location: ' . $auth_url); + exit(); +} ?> \ No newline at end of file