1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/4/26
- * Time: 下午2:46
- */
- require_once (BASE_ROOT_PATH . '/helper/third_author/wxauthor.php');
- require_once (BASE_ROOT_PATH . '/helper/session.php');
- ini_set('date.timezone','Asia/Shanghai');
- error_reporting(E_ERROR);
- $code = $_GET['code'];
- $state = $_GET['state'];
- Log::record("state:{$state} originurl=" . wechat_helper::get_origin_url(),Log::DEBUG);
- if(empty($code)) {
- Log::record("没有同意授权");
- }
- elseif(wechat_helper::has_origin_url())
- {
- $author = new thrid_author\wxauthor();
- $user_info = $author->callback($code);
- if(empty($user_info)) {
- Log::record("微信取到的信息为空",Log::DEBUG);
- }
- else
- {
- wechat_helper::set_userinfo($user_info);
- $origin_url = wechat_helper::get_origin_url();
- wechat_helper::clear_origin_url();
- Log::record("origin_url={$origin_url}",Log::DEBUG);
- if(!empty($origin_url))
- {
- $html = "<!DOCTYPE html>
- <html lang=\"en\">
- <head>
- <meta charset=\"UTF-8\">
- <meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\" />
- <meta http-equiv=\"Pragma\" content=\"no-cache\" />
- <meta http-equiv=\"Expires\" content=\"0\" />
- <title>跳转中</title>
- </head>
- <body>
- <script>
- window.location.replace(\"{$origin_url}\");
- </script>
- </body>
- </html>";
- echo $html;
- }
- }
- }
- else
- {
- $host = urldecode($state);
- $url = "{$host}/mobile/wxauthor.php?code={$code}";
- Log::record("redirect url={$url}",Log::DEBUG);
- $html = "<!DOCTYPE html>
- <html lang=\"en\">
- <head>
- <meta charset=\"UTF-8\">
- <meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\" />
- <meta http-equiv=\"Pragma\" content=\"no-cache\" />
- <meta http-equiv=\"Expires\" content=\"0\" />
- <title>跳转中</title>
- </head>
- <body>
- <script>
- window.location.replace(\"{$url}\");
- </script>
- </body>
- </html>";
- echo $html;
- }
|