作者 刘锟

update

@@ -102,7 +102,7 @@ class CreateSite extends Command @@ -102,7 +102,7 @@ class CreateSite extends Command
102 } 102 }
103 103
104 try { 104 try {
105 - $rs = HttpUtils::get($api_url, $api_param); 105 + $rs = HttpUtils::get($api_url, $api_param, [], 180);
106 $rs = json_decode($rs, true); 106 $rs = json_decode($rs, true);
107 if (isset($rs['status']) && $rs['status'] == 200) { 107 if (isset($rs['status']) && $rs['status'] == 200) {
108 $this->output($domain_info['domain'] . ',主站创建成功'); 108 $this->output($domain_info['domain'] . ',主站创建成功');
@@ -128,7 +128,7 @@ class CreateSite extends Command @@ -128,7 +128,7 @@ class CreateSite extends Command
128 } 128 }
129 129
130 try { 130 try {
131 - $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp); 131 + $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp, [], 180);
132 $rs_amp = json_decode($rs_amp, true); 132 $rs_amp = json_decode($rs_amp, true);
133 if (isset($rs_amp['status']) && $rs_amp['status'] == 200) { 133 if (isset($rs_amp['status']) && $rs_amp['status'] == 200) {
134 $this->output($domain_info['domain'] . ',amp站创建成功'); 134 $this->output($domain_info['domain'] . ',amp站创建成功');
@@ -39,18 +39,18 @@ class HttpUtils @@ -39,18 +39,18 @@ class HttpUtils
39 * @return int 39 * @return int
40 * @throws \GuzzleHttp\Exception\GuzzleException 40 * @throws \GuzzleHttp\Exception\GuzzleException
41 */ 41 */
42 - public static function get($url, $data, $headers = []) 42 + public static function get($url, $data, $headers = [],$timeout=60)
43 { 43 {
44 LogUtils::info("HttpUtils-GET请求URL:" . $url); 44 LogUtils::info("HttpUtils-GET请求URL:" . $url);
45 - $response = Http::timeout(60)->withHeaders($headers)->get($url, $data); 45 + $response = Http::timeout($timeout)->withHeaders($headers)->get($url, $data);
46 self::checkSuccess($response); 46 self::checkSuccess($response);
47 return $response->getBody()->getContents(); 47 return $response->getBody()->getContents();
48 } 48 }
49 49
50 - public static function post($url, $data, $headers = []) 50 + public static function post($url, $data, $headers = [],$timeout=60)
51 { 51 {
52 LogUtils::info("HttpUtils-POST请求URL:" . $url); 52 LogUtils::info("HttpUtils-POST请求URL:" . $url);
53 - $response = Http::timeout(60)->withHeaders($headers)->post($url, $data); 53 + $response = Http::timeout($timeout)->withHeaders($headers)->post($url, $data);
54 self::checkSuccess($response); 54 self::checkSuccess($response);
55 return $response->getBody()->getContents(); 55 return $response->getBody()->getContents();
56 } 56 }