|
@@ -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)];
|
|
|
- }
|
|
|
}
|