dyjh 6 years ago
parent
commit
af2695c95d
1 changed files with 19 additions and 21 deletions
  1. 19 21
      app/Http/Controllers/Web/AuthController.php

+ 19 - 21
app/Http/Controllers/Web/AuthController.php

xqd xqd
@@ -73,26 +73,8 @@ class AuthController extends Controller
     public function notifyAccount(Request $request)
     {
         /**/
-        $echoStr = $_GET["echostr"];
-        //如果有$echoStr说明是对接
-        if (!empty($echoStr)) {
-            //对接规则
-            $signature = $_GET["signature"];
-            $timestamp = $_GET["timestamp"];
-            $nonce = $_GET["nonce"];
-            $token = 'bshbdajdbjadwedwqer';
-            $tmpArr = array($token, $timestamp, $nonce);
-            sort($tmpArr, SORT_STRING);
-            $tmpStr = implode($tmpArr);
-            $tmpStr = sha1($tmpStr);
-            if ($tmpStr == $signature) {
-                echo $echoStr;
-            } else {
-                echo "";
-                exit;
-            }
-        } else {
-            \Log::info("111");
+
+            \Log::info("111");$this->checkSignature();
             $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
             if (!empty($postStr)) {
                 $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
@@ -106,10 +88,26 @@ class AuthController extends Controller
                 echo "";
                 exit;
             }
-        }
     }
 
 
+    private function checkSignature()
+    {
+        $signature = $_GET["signature"];
+        $timestamp = $_GET["timestamp"];
+        $nonce = $_GET["nonce"];
+        $token = 'bshbdajdbjadwedwqer';
+        $tmpArr = array($token, $timestamp, $nonce);
+        sort($tmpArr);
+        $tmpStr = implode($tmpArr);
+        $tmpStr = sha1($tmpStr);
+        if ($tmpStr == $signature) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     public function welcome()
     {
         return view('welcome');