提交其他文件

This commit is contained in:
2026-03-11 18:24:59 +08:00
parent 4b490670f1
commit f0d7f60fd5
1377 changed files with 73456 additions and 0 deletions

View File

@ -0,0 +1,58 @@
<?php
namespace app\common\service\iot;
class SpeakerService
{
// 基础配置
private $url = 'https://speaker.17laimai.cn/notify.php';
private $token = 'HK1654603135';
private $version = 1;
/**
* 语音播报
* @return mixed
*/
public function sendSpeakerNotify($speakerId)
{
$data = [
'version' => $this->version,
'token' => $this->token,
'id' => $speakerId,
'message' => '您好您预约的时间段还有10分钟即将结束',
];
return $this->curlPost($this->url, $data);
}
private function curlPost($url, $data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
// 增加SSL选项如果是HTTPS
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
// 添加错误处理
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
curl_close($ch);
throw new \Exception("CURL请求失败: " . $error_msg);
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $result;
}
}