陈德本 il y a 5 ans
Parent
commit
77f7fb3f4f
1 fichiers modifiés avec 14 ajouts et 9 suppressions
  1. 14 9
      App/Api/Controller/ReceivedSms.php

+ 14 - 9
App/Api/Controller/ReceivedSms.php

@@ -18,22 +18,27 @@ class ReceivedSms extends RestfulController
 
     protected function getData()
     {
-        $data=file(APP_DIR . "/test_msg.txt");
-        $result=[];
+        $data = file(APP_DIR . "/test_msg.txt");
+        $result = [];
         foreach ($data as $datum) {
-            $temp=explode("$$$", $datum);
-            $result[]=[
-                'from'=>$temp[1],
-                'to'=>$temp[2],
-                'msg'=>$temp[0]
-            ];
+            $pat = "#-[操作:(.*)]#";
+            preg_match($pat, $datum, $arr);
+            if ($arr[1]) {
+                $temp = explode("$$$", $arr[1]);
+                $result[] = [
+                    'from' => $temp[1],
+                    'to' => $temp[2],
+                    'msg' => $temp[0]
+                ];
+            }
+
         }
         $this->showSuccess($result);
     }
 
     protected function postData()
     {
-        Logger::setLog(file_get_contents("php://input"),APP_DIR . "/test_msg.txt");
+        Logger::setLog(file_get_contents("php://input"), APP_DIR . "/test_msg.txt");
     }
 
     protected function putData()