From 7395229cff24c068db92dfced1aea17dfb22ef49 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Thu, 26 Oct 2023 16:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=B4=E6=92=AD=E9=80=81?= =?UTF-8?q?=E7=A4=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/user/Zhibo.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/controller/api/user/Zhibo.php b/app/controller/api/user/Zhibo.php index 77b0362b..e9d0d002 100644 --- a/app/controller/api/user/Zhibo.php +++ b/app/controller/api/user/Zhibo.php @@ -43,16 +43,23 @@ class Zhibo extends BaseController } $token = request()->header('x-token'); //查询直播间及礼物接口,验证直播间信息及礼物信息 - $client = new Client(); - $response = $client->request('POST', $this->checkUrl, [ - 'verify' => false, - 'headers' => ['X-Token' => $token], - 'json' => [ - "live_stream_id" => $params['live_stream_id'], - "master_id" => $params['master_id'], - "gift_id" => $params['gift_id'] - ] - ]); + + try { + $client = new Client(); + $response = $client->request('POST', $this->checkUrl, [ + 'timeout' => 5, + 'verify' => false, + 'headers' => ['X-Token' => $token], + 'json' => [ + "live_stream_id" => $params['live_stream_id'], + "master_id" => $params['master_id'], + "gift_id" => $params['gift_id'] + ] + ]); + $responseData = json_decode($response->getBody()->getContents(), true); + } catch (RequestException $e) { + return app('json')->fail($e->getMessage()); + } $responseData = json_decode($response->getBody()->getContents(), true); if (empty($responseData['code'])) { $failMsg = $responseData['msg'];