Total Complexity | 8 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
3 | class WxProxy |
||
4 | { |
||
5 | protected $AuthorizeURL = 'https://open.weixin.qq.com/connect/oauth2/authorize'; |
||
6 | |||
7 | public function run() |
||
8 | { |
||
9 | if (isset($_GET['code'])) { |
||
10 | header('Location: ' . $_COOKIE['return_uri'] . '?code=' . $_GET['code'] . '&state=' . $_GET['state']); |
||
11 | } else { |
||
12 | $protocol = $this->is_HTTPS() ? 'https://' : 'http://'; |
||
13 | $params = array( |
||
14 | 'appid' => $_GET['appid'], |
||
15 | 'redirect_uri' => $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['DOCUMENT_URI'], |
||
16 | 'response_type' => $_GET['response_type'], |
||
17 | 'scope' => $_GET['scope'], |
||
18 | 'state' => $_GET['state'], |
||
19 | ); |
||
20 | setcookie('return_uri', urldecode($_GET['return_uri']), $_SERVER['REQUEST_TIME'] + 60, '/'); |
||
21 | header('Location: ' . $this->AuthorizeURL . '?' . http_build_query($params) . '#wechat_redirect'); |
||
22 | } |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * 是否https |
||
27 | */ |
||
28 | protected function is_HTTPS() |
||
41 | } |
||
42 | } |
||
46 |