zxhxx 3 vuotta sitten
vanhempi
commit
80e17315d1
2 muutettua tiedostoa jossa 37 lisäystä ja 2 poistoa
  1. 30 0
      application/common.php
  2. 7 2
      extend/liuniu/UtilService.php

+ 30 - 0
application/common.php

@@ -546,4 +546,34 @@ if (!function_exists('get_all_categories')) {
         }
         return $list;
     }
+}
+if (!function_exists('do_request')) {
+    function do_request($url, $data, $header = null, $post = true, $json = false, $format = 0, $form = false)
+    {
+        $curl = curl_init();
+        curl_setopt($curl, CURLOPT_URL, $url);
+        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+        if ($post) {
+            curl_setopt($curl, CURLOPT_POST, 1);
+            if (!$json && !$form) {
+                curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
+            } else if ($json && !$form) {
+                curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data, $format));
+            } else {
+                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+            }
+        }
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+        if ($header) {
+            curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
+            curl_setopt($curl, CURLOPT_HEADER, 0);
+        }
+        $result = curl_exec($curl);
+        if (curl_errno($curl)) {
+            return json_encode(['status' => curl_errno($curl), 'msg' => '请求失败']);
+        }
+        curl_close($curl);
+        return $result;
+    }
 }

+ 7 - 2
extend/liuniu/UtilService.php

@@ -172,12 +172,17 @@ class UtilService
             $data['path'] = $param['path'];
             $data['query'] = $param['query'];
             $data['is_expire'] = false;
-            $res = HttpService::postRequest($url, $data,false,10,true);
-            $res = file_get_contents($url);
+            $res = do_request($url,$data,null,true,true);
             cache('link_' . $cid,json_decode($res,true));
         }
         return cache('link_' . $cid);
     }
+    public static function http($url,)
+    {
+
+
+
+    }
 
 
 }