Procházet zdrojové kódy

添加助手函数

durong před 5 roky
rodič
revize
9c76ce863a
1 změnil soubory, kde provedl 17 přidání a 0 odebrání
  1. 17 0
      app/Helper/helper.php

+ 17 - 0
app/Helper/helper.php

@@ -24,4 +24,21 @@ if ( ! function_exists('config_path'))
         return $text;
     }
 }
+}
+
+function http($url, $param, $method = 'post')
+{
+    try {
+        $client = new \GuzzleHttp\Client();
+        $response = $client->request($method, $url, $param);
+        $result = json_decode($response->getBody()->getContents(), true);
+        if ($result['code'] == 0) {
+            return $result['data'];
+        } else {
+            return [];
+        }
+    } catch (\Exception $exception) {
+        return [];
+    }
+
 }