cqp 6 днів тому
батько
коміт
1ebff8ef4b
2 змінених файлів з 28 додано та 28 видалено
  1. 0 28
      app/Service/ProductService.php
  2. 28 0
      app/Service/Service.php

+ 0 - 28
app/Service/ProductService.php

@@ -1710,32 +1710,4 @@ class ProductService extends Service
 
         return [true, ''];
     }
-
-    public function post_helper($url, $data, $header = [], $timeout = 20){
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch,  CURLOPT_RETURNTRANSFER, true);
-        curl_setopt($ch, CURLOPT_ENCODING, '');
-        curl_setopt($ch, CURLOPT_POST, 1);
-        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
-        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
-        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
-
-        if(!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-        $r = curl_exec($ch);
-
-        if ($r === false) {
-            // 获取错误号
-            $errorNumber = curl_errno($ch);
-            // 获取错误信息
-            $errorMessage = curl_error($ch);
-            $message = "cURL Error #{$errorNumber}: {$errorMessage}";
-
-            return [false, $message];
-        }
-        curl_close($ch);
-
-        return [true, json_decode($r, true)];
-    }
 }

+ 28 - 0
app/Service/Service.php

@@ -616,4 +616,32 @@ class Service
 
         return $days;
     }
+
+    public function post_helper($url, $data, $header = [], $timeout = 20){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch,  CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_ENCODING, '');
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+
+        if(!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        $r = curl_exec($ch);
+
+        if ($r === false) {
+            // 获取错误号
+            $errorNumber = curl_errno($ch);
+            // 获取错误信息
+            $errorMessage = curl_error($ch);
+            $message = "cURL Error #{$errorNumber}: {$errorMessage}";
+
+            return [false, $message];
+        }
+        curl_close($ch);
+
+        return [true, json_decode($r, true)];
+    }
 }