jsapi
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user