|
|
|
@ -15,8 +15,10 @@ $auth_url = 'https://open.weixin.qq.com/connect/oauth2/authorize' |
|
|
|
. '&state=STATE'; // wechat_redirect |
|
|
|
|
|
|
|
// 如果用户已经授权,则重定向到回调URL,并获取用户的openid |
|
|
|
if (isset($_GET['code'])) { |
|
|
|
$code = $_GET['code']; |
|
|
|
// if (isset($_GET['code'])) { |
|
|
|
// $code = $_GET['code']; |
|
|
|
|
|
|
|
$code = '100010'; |
|
|
|
|
|
|
|
// 构造获取access_token的URL |
|
|
|
$token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token' |
|
|
|
@ -56,9 +58,9 @@ if (isset($_GET['code'])) { |
|
|
|
|
|
|
|
// // 在这里处理获取到的openid |
|
|
|
// echo $openid; |
|
|
|
} else { |
|
|
|
// 如果没有授权,则重定向到授权页面 |
|
|
|
header('Location: ' . $auth_url); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
// } else { |
|
|
|
// // 如果没有授权,则重定向到授权页面 |
|
|
|
// header('Location: ' . $auth_url); |
|
|
|
// exit(); |
|
|
|
// } |
|
|
|
?> |