2 Star 9 Fork 1

Walkline/天猫精灵语音技能

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
aligenie.php 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
Walkline 提交于 2020-07-17 14:11 . 增加猫精请求解析类文件
<?php
class AligenieIAP
{
public $utterance = "";
public $request_city = "";
public $skill_name = "";
public $intent_name = "";
public $slot_location = "";
public $slot_date = "";
function __construct($post_data) {
$json_obj = json_decode($post_data, true);
$this->utterance = $json_obj['utterance'];
$this->skill_name = $json_obj['skillName'];
$this->intent_name = $json_obj['intentName'];
$this->request_city = @$json_obj['requestData']['city'];
$slots = @$json_obj['slotEntities'];
if (!empty($slots)) {
foreach ($slots as $slot) {
$intentParameterName = $slot['intentParameterName'];
if ($this->startsWith($intentParameterName, "sys.location")) {
$this->slot_location = $slot['slotValue'];
} else if ($this->startsWith($intentParameterName, "sys.date")) {
$this->slot_date = json_decode($slot['slotValue'], true)['iDateString'];
}
}
}
}
public function toString() {
return "Aligenie IAP request object:\n" .
"\tutterance: $this->utterance\n" .
"\trequest_city: $this->request_city\n" .
"\tskill_name: $this->skill_name\n" .
"\tintent_name: $this->intent_name\n" .
"\tslot_location: $this->slot_location\n" .
"\tslot_date: $this->slot_date\n";
}
private function startsWith($haystack, $needle) {
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
}
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/walkline/aligenie_voice_skills.git
[email protected]:walkline/aligenie_voice_skills.git
walkline
aligenie_voice_skills
天猫精灵语音技能
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385