From acdabea76e7f99beb31a764438149657e6c7609c Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 26 Feb 2026 16:11:40 +0800 Subject: [PATCH] jsapi --- app/common/utils/Feishu.php | 39 +++++++------------------------------ 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/app/common/utils/Feishu.php b/app/common/utils/Feishu.php index cdd6d16..b1260dc 100644 --- a/app/common/utils/Feishu.php +++ b/app/common/utils/Feishu.php @@ -269,17 +269,16 @@ class Feishu return $cachedTicket; } - $url = $this->baseUri . '/jssdk/ticket/get'; - - $headers = [ - 'Authorization: Bearer ' . $accessToken, - 'Content-Type: application/json' + // 使用 requestResult 方法发起请求,而不是 httpGet + $this->options["headers"] = [ + "Authorization" => "Bearer " . $accessToken, + "Content-Type" => "application/json; charset=utf-8" ]; - $result = $this->httpGet($url, $headers); + $result = $this->requestResult('jssdk/ticket/get', 'GET'); - if ($result['code'] !== 0) { - throw new BusinessException('获取 jsapi_ticket 失败: ' . json_encode($result)); + if (!$result) { + throw new BusinessException('获取 jsapi_ticket 失败: ' . $this->error()); } $ticket = $result['data']['ticket']; @@ -322,28 +321,4 @@ class Feishu } return $str; } - - /** - * HTTP GET 请求 - */ - private function httpGet($url, $headers = []) - { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_TIMEOUT, 10); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 不验证证书 - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 不验证主机名 - - $response = curl_exec($ch); - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); - - if ($httpCode !== 200) { - throw new BusinessException("HTTP GET 请求失败: {$httpCode}"); - } - - return json_decode($response, true); - } } \ No newline at end of file