Commit de6a46b1 by 庄欣

无反应时

parent 81419de5
...@@ -12,7 +12,7 @@ class CurlClient ...@@ -12,7 +12,7 @@ class CurlClient
protected $config; protected $config;
protected $data; protected $data;
protected $url; protected $url;
private $format = "JSON"; private $format = "";
protected $header = []; protected $header = [];
protected $base; protected $base;
...@@ -84,7 +84,7 @@ class CurlClient ...@@ -84,7 +84,7 @@ class CurlClient
curl_setopt($http,CURLOPT_URL,$this->base.$this->url); curl_setopt($http,CURLOPT_URL,$this->base.$this->url);
curl_setopt($http,CURLOPT_HEADER,false); curl_setopt($http,CURLOPT_HEADER,false);
curl_setopt($http,CURLOPT_CUSTOMREQUEST,$this->method); curl_setopt($http,CURLOPT_CUSTOMREQUEST,$this->method);
curl_setopt($http,CURLOPT_TIMEOUT ,5); curl_setopt($http,CURLOPT_TIMEOUT ,3);
if ($this->format == "JSON") if ($this->format == "JSON")
{ {
$this->header = array_merge($this->header,['Content-Type:application/json']); $this->header = array_merge($this->header,['Content-Type:application/json']);
...@@ -115,11 +115,11 @@ class CurlClient ...@@ -115,11 +115,11 @@ class CurlClient
} }
$res = $response_from_api[$sign]; $res = $response_from_api[$sign];
} else {*/ } else {*/
$res = curl_exec($http); $res = curl_multi_exec($http);
$curlinfo = curl_getinfo($http); $curlinfo = curl_getinfo($http);
//} //}
curl_close($http);
if ($curlinfo == false || (is_array($curlinfo) && $curlinfo['http_code'] != 200)) { if ($curlinfo == false || (is_array($curlinfo) && $curlinfo['http_code'] != 200)) {
die(json_encode($curlinfo));
throw new \Exception("服务器无反应,请稍候再试"); throw new \Exception("服务器无反应,请稍候再试");
} }
$res = json_decode($res); $res = json_decode($res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment