Browse Source

test

master
用户名 3 years ago
parent
commit
d6c15f0c42
  1. 18
      mobile/testsc2.php

18
mobile/testsc2.php

@ -11,14 +11,14 @@ $auth_url = 'https://open.weixin.qq.com/connect/oauth2/authorize'
. '?appid=' . urlencode($appid) . '?appid=' . urlencode($appid)
. '&redirect_uri=' . urlencode($redirect_uri) . '&redirect_uri=' . urlencode($redirect_uri)
. '&response_type=code' . '&response_type=code'
. '&scope=snsapi_base' // snsapi_base 只获取openid,snsapi_userinfo 获取用户信息 . '&scope=snsapi_userinfo' // snsapi_base 只获取openid,snsapi_userinfo 获取用户信息
. '&state=STATE'; // wechat_redirect . '&state=STATE'; // wechat_redirect
// 如果用户已经授权,则重定向到回调URL,并获取用户的openid // 如果用户已经授权,则重定向到回调URL,并获取用户的openid
// if (isset($_GET['code'])) { if (isset($_GET['code'])) {
// $code = $_GET['code']; $code = $_GET['code'];
$code = '100010'; // $code = '100010';
// 构造获取access_token的URL // 构造获取access_token的URL
$token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token' $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 // // 在这里处理获取到的openid
// echo $openid; // echo $openid;
// } else { } else {
// // 如果没有授权,则重定向到授权页面 // 如果没有授权,则重定向到授权页面
// header('Location: ' . $auth_url); header('Location: ' . $auth_url);
// exit(); exit();
// } }
?> ?>
Loading…
Cancel
Save