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