stanley-king 7 gadi atpakaļ
vecāks
revīzija
ab932c473f
3 mainītis faili ar 44 papildinājumiem un 28 dzēšanām
  1. 3 3
      helper/session_helper.php
  2. 1 1
      helper/third_author/wxauthor.php
  3. 40 24
      mobile/wxauthor.php

+ 3 - 3
helper/session_helper.php

@@ -251,9 +251,9 @@ class session_helper
 
     static public function need_wechat_author()
     {
-        if (BASE_SITE_URL != 'http://p.lrlz.com') {
-            return false;
-        }
+//        if (BASE_SITE_URL != 'http://p.lrlz.com') {
+//            return false;
+//        }
 
         if (util::from_wechat() == false) {
             return false;

+ 1 - 1
helper/third_author/wxauthor.php

@@ -35,7 +35,7 @@ class wxauthor
 
     public function enter($origin_url)
     {
-        $back_url = BASE_SITE_URL . '/mobile/wxauthor.php';
+        $back_url = 'http://p.lrlz.com/mobile/wxauthor.php';
         $params = [ 'appid' => self::appid,
                     'redirect_uri' => $back_url,
                     'response_type' => 'code',

+ 40 - 24
mobile/wxauthor.php

@@ -12,26 +12,25 @@ require_once (BASE_ROOT_PATH . '/helper/session.php');
 ini_set('date.timezone','Asia/Shanghai');
 error_reporting(E_ERROR);
 
-$code = $_GET['code'];
+$code  = $_GET['code'];
+$state = $_GET['state'];
+
 if(empty($code)) {
     Log::record("没有同意授权");
 }
 else
 {
-    $author = new \thrid_author\wxauthor();
-    $user_info = $author->callback($code);
-    if($user_info == false)
-    {
-        Log::record("微信取到的信息为空",Log::DEBUG);
-    }
-    else
+    if(array_key_exists('author_orgin_url',$_SESSION))
     {
-        $_SESSION['wx_author']['user_info'] = $user_info;
-        $_SESSION['wx_author']['handled'] = false;
-
+        $author = new \thrid_author\wxauthor();
+        $user_info = $author->callback($code);
+        if(empty($user_info)) {
+            Log::record("微信取到的信息为空",Log::DEBUG);
+        }
+        else {
+            $_SESSION['wx_author']['user_info'] = $user_info;
+            $_SESSION['wx_author']['handled'] = false;
 
-        if(array_key_exists('author_orgin_url',$_SESSION))
-        {
             $origin_url = $_SESSION['author_orgin_url'];
             unset($_SESSION['author_orgin_url']);
 
@@ -39,20 +38,37 @@ else
             if(!empty($origin_url))
             {
                 $html = "<!DOCTYPE html>
-                            <html lang=\"en\">
-                            <head>
-                                <meta charset=\"UTF-8\">
-                                <title>跳转中</title>
-                            </head>
-                            <body>
-                            <script>
-                                window.location.href =\"{$origin_url}\";
-                            </script>
-                            </body>
-                            </html>";
+                        <html lang=\"en\">
+                        <head>
+                            <meta charset=\"UTF-8\">
+                            <title>跳转中</title>
+                        </head>
+                        <body>
+                        <script>
+                            window.location.href =\"{$origin_url}\";
+                        </script>
+                        </body>
+                        </html>";
 
                 echo $html;
             }
         }
     }
+    else {
+        $url = "http://devlrlz.s1.natapp.cc/mobile/wxauthor.php?code={$code}&state={$state}";
+        $html = "<!DOCTYPE html>
+                        <html lang=\"en\">
+                        <head>
+                            <meta charset=\"UTF-8\">
+                            <title>跳转中</title>
+                        </head>
+                        <body>
+                        <script>
+                            window.location.href =\"{$url}\";
+                        </script>
+                        </body>
+                        </html>";
+
+        echo $html;
+    }
 }