Explorar o código

添加助手函数

durong %!s(int64=5) %!d(string=hai) anos
pai
achega
9c76ce863a
Modificáronse 1 ficheiros con 17 adicións e 0 borrados
  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 [];
+    }
+
 }