You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1491 lines
57 KiB
1491 lines
57 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: rainfer <81818832@qq.com>
|
|
// +----------------------------------------------------------------------
|
|
class Alichat
|
|
{
|
|
private $method = 'GET';
|
|
private $api = 'http://chatbot.cn-shanghai.aliyuncs.com';//接口
|
|
private $dateTimeFormat = 'Y-m-d\TH:i:s\Z';
|
|
private $config = [
|
|
'Format' => 'json',
|
|
'ServiceCode' => "beeboot",
|
|
'RegionId' => "cn-shanghai",
|
|
'Version' => '2017-10-11',
|
|
'SignatureMethod' => 'HMAC-SHA1',
|
|
'SignatureVersion' => "1.0",
|
|
'AccessKeyId' => 'LTAI5tS2cBUXxUG591esJqBq',
|
|
'accessKeySecret' => 'LeXSrnBR1GRfbXEyTyX9sai28pb0EF',
|
|
];
|
|
protected function createdata(){
|
|
date_default_timezone_set("GMT");
|
|
$dateTimeFormat = 'Y-m-d\TH:i:s\Z'; // ISO8601规范
|
|
return array(
|
|
'Version' => $this->config['Version'],
|
|
'ServiceCode' =>$this->config['ServiceCode'],
|
|
'RegionId' =>$this->config['RegionId'],
|
|
'Format' => $this->config['Format'],
|
|
'AccessKeyId' => $this->config['AccessKeyId'],
|
|
'SignatureVersion' => $this->config['SignatureVersion'],
|
|
'SignatureMethod' => $this->config['SignatureMethod'],
|
|
'Timestamp' => date($dateTimeFormat),
|
|
'SignatureNonce' => md5('estxiu.com').rand(100000,999999).uniqid(), //唯一随机数
|
|
);
|
|
}
|
|
public function __construct($config = []){
|
|
$this->config($config);
|
|
}
|
|
/*读取配置*/
|
|
public function config($config = []){
|
|
/**
|
|
*@AccessKeyId 阿里云申请的 Access Key ID
|
|
*@AccessKeySecret 阿里云申请的 Access Key Secret
|
|
*/
|
|
$this->config = array_merge($this->config, $config);
|
|
return $this;
|
|
}
|
|
/**
|
|
*发送视⻆ - 列表
|
|
*PerspectiveId String 视⻆主键(code_id)
|
|
*PerspectiveCode String 视⻆编码(⽤于问答api)
|
|
*ModifyTime String 修改时间 UTC时间
|
|
*CreateTime String 创建时间 UTC时间
|
|
*SelfDefine Boolean 是否⾃定义
|
|
* Status Integer 数据状态:3:选中;1:未选中
|
|
* Name String 视⻆名称
|
|
*/
|
|
public function perspect()
|
|
{
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryPerspectives'
|
|
);
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
//var_dump($data);exit;
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
public function perspectDetail($PerspectiveId='')
|
|
{
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribePerspective',
|
|
'PerspectiveId'=>$PerspectiveId
|
|
);
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 视⻆ - 创建
|
|
*/
|
|
public function createPerspect($name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreatePerspective',
|
|
'Name'=>$name
|
|
);
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 视⻆ - 修改
|
|
*/
|
|
public function editPerspect($name='',$perid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdatePerspective',
|
|
'Name'=>$name,
|
|
'PerspectiveId'=>$perid
|
|
);
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 视⻆ - 启⽤
|
|
*/
|
|
public function activePerspect($perid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ActivatePerspective',
|
|
'PerspectiveId'=>$perid
|
|
);
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 知识库 - 类⽬ - 列表
|
|
*/
|
|
public function categories($pid=-1,$show=false){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryCategories'
|
|
);
|
|
if($pid)$data['ParentCategoryId']=$pid;
|
|
if($show)$data['ShowChildrens']=$show;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 类⽬ - 详情
|
|
*/
|
|
public function categoryDetail($cid=-1){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeCategory'
|
|
);
|
|
if($cid)$data['CategoryId']=$cid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 类⽬ - 新增
|
|
*/
|
|
public function createCategory($pid=-1,$name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreateCategory'
|
|
);
|
|
if($pid)$data['ParentCategoryId']=$pid;
|
|
$data['Name']=$name;
|
|
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 类⽬ - 修改
|
|
*/
|
|
public function editCategory($cid=-1,$name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdateCategory'
|
|
);
|
|
if($cid)$data['CategoryId']=$cid;
|
|
$data['Name']=$name;
|
|
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 类⽬ - 删除
|
|
*CategoryId Long 是 类⽬Id,唯⼀标志
|
|
*/
|
|
public function delCategory($cid=-1){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DeleteCategory'
|
|
);
|
|
if($cid)$data['CategoryId']=$cid;
|
|
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 核⼼词 - 列表
|
|
*CoreWordName String 是 核⼼词名称
|
|
*PageNumber Integer 否 分⻚-第⼏⻚,默认1
|
|
*PageSize Integer 否 分⻚-⻚⾯⼤⼩,默认 10
|
|
*Synonym String 否 核⼼词的同义词
|
|
*/
|
|
public function coreWords($name='',$page=1,$size=10,$synon=false){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryCoreWords'
|
|
);
|
|
if($name)$data['CoreWordName']=$name;
|
|
$data['PageNumber']=$page;
|
|
$data['PageSize']=$size;
|
|
$data['Synonym']=$synon;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
*知识库 - 核⼼词 - 详情
|
|
*CoreWordName String 是 名称
|
|
*/
|
|
public function describeWord($name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeCoreWord'
|
|
);
|
|
if($name)$data['CoreWordName']=$name;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
*知识库 - 核⼼词 - 创建
|
|
*CoreWordName String 是 核⼼词名称
|
|
*/
|
|
public function createWord($name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreateCoreWord'
|
|
);
|
|
if($name)$data['CoreWordName']=$name;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 核⼼词 - 修改
|
|
*CoreWordCode String 是 唯⼀编码
|
|
* CoreWordName String 是 核⼼词
|
|
*/
|
|
public function editWord($code='',$name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdateCoreWord'
|
|
);
|
|
if($code)$data['CoreWordCode']=$code;
|
|
if($name)$data['CoreWordName']=$name;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 核⼼词 - 删除
|
|
*CoreWordName String 是 唯⼀标识
|
|
*/
|
|
public function delWord($name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DeleteCoreWord'
|
|
);
|
|
if($name)$data['CoreWordName']=$name;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 核⼼词 - 同义词添加
|
|
*CoreWordName String 是 核⼼词名称
|
|
*Synonym String 是 同义词
|
|
*/
|
|
public function addSynon($name='',$synon=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'AddSynonym'
|
|
);
|
|
$data['CoreWordName']=$name;
|
|
$data['Synonym']=$synon;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 核⼼词 - 同义词删除
|
|
*CoreWordName String 是 核⼼词名称
|
|
* Synonym String 是 同义词
|
|
*/
|
|
public function delSynon($name='',$synon=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'RemoveSynonym'
|
|
);
|
|
$data['CoreWordName']=$name;
|
|
$data['Synonym']=$synon;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 - 列表
|
|
*KnowledgeTitle String 否 知识标题
|
|
*CoreWordName String 否 核⼼词
|
|
*PageNumber Integer 否 分⻚-第⼏⻚,默认1
|
|
*PageSize Integer 否 分⻚-⻚⾯⼤⼩,默认 10
|
|
*CategoryId Long 否 知识类⽬ID
|
|
*/
|
|
public function knowledges($cid='',$title='',$name='',$page=1,$size=10){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryKnowledges'
|
|
);
|
|
if($title)$data['KnowledgeTitle']=$title;
|
|
if($name)$data['CoreWordName']=$name;
|
|
$data['PageNumber']=$page;
|
|
$data['PageSize']=$size;
|
|
if($cid)$data['CategoryId']=$cid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 - 详情
|
|
*KnowledgeId Long 是 知识唯⼀标识
|
|
*/
|
|
public function describeknow($kid){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeKnowledge'
|
|
);
|
|
$data['KnowledgeId']=$kid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 - 创建并发布
|
|
*Knowledge String 是 知识数据,⻅
|
|
*
|
|
*Knowledge
|
|
*CategoryId Long 是 类⽬ID
|
|
*KnowledgeTitle String 是 标题
|
|
* KnowledgeType Integer 否 知识类型:1:普通知识 5:⽂档知识(私有 云)
|
|
* StartDate String 否 ⽣效时间(UTC时间)
|
|
* EndDate String 否 失效时间(UTC时间)
|
|
* Solutions Array of Solution 是 ⽂本型知识答案
|
|
* Outlines Array of Outline 否 关联知识(私有云)
|
|
* SimQuestions Array of SimQuestion 否 相似问题
|
|
*KeyWords Array of String 否 关键词(划词)(私有 云)
|
|
*CoreWords Array of String 否 核⼼词
|
|
*
|
|
*SimQuestion
|
|
* Title String 是 相似问法标题
|
|
*
|
|
* Solution
|
|
* Content String 是 富⽂本内容
|
|
* PlainText String 是 纯⽂本内容
|
|
* PerspectiveIds Array of String 是 视⻆id列表
|
|
*
|
|
* Outline
|
|
* KnowledgeId Long 是 知识id
|
|
* Title String 是 知识题⽬
|
|
*/
|
|
public function createknow($know=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreateKnowledge'
|
|
);
|
|
$know=json_encode($know);
|
|
$data['Knowledge']=$know;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 - 修改并发布
|
|
*Knowledge String 是 知识数据,⻅
|
|
*
|
|
*Knowledge
|
|
*KnowledgeId Long 是 知识ID
|
|
*CategoryId Long 是 类⽬ID
|
|
*KnowledgeTitle String 是 标题
|
|
* KnowledgeType Integer 否 知识类型:1:普通知识 5:⽂档知识(私有 云)
|
|
* StartDate String 否 ⽣效时间(UTC时间)
|
|
* EndDate String 否 失效时间(UTC时间)
|
|
* Solutions Array of Solution 是 ⽂本型知识答案
|
|
* Outlines Array of Outline 否 关联知识(私有云)
|
|
* SimQuestions Array of SimQuestion 否 相似问题
|
|
*KeyWords Array of String 否 关键词(划词)(私有 云)
|
|
*CoreWords Array of String 否 核⼼词
|
|
*
|
|
*SimQuestion
|
|
*SimQuestionId Long 否 相似问法Id,当Action 为ADD时可空
|
|
* Title String 是 相似问法标题
|
|
* Action String 是 操作类型:追加: ADD,修改:UPD,移 除:DEL
|
|
*
|
|
* Solution
|
|
* SolutionId Long 否 Solution Id主键, 新增 时可空
|
|
* Content String 是 富⽂本内容
|
|
* PlainText String 是 纯⽂本内容
|
|
* PerspectiveIds Array of String 是 视⻆id列表
|
|
*
|
|
* Outline
|
|
* OutlineId Long 否 关联关系Id,当Action为 ADD时可空
|
|
* KnowledgeId Long 是 知识id
|
|
* Title String 是 知识题⽬
|
|
*/
|
|
public function editknow($know=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdateKnowledge'
|
|
);
|
|
$know=json_encode($know);
|
|
$data['Knowledge']=$know;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 - 删除
|
|
KnowledgeId Long 是 待删除知识id
|
|
*/
|
|
public function delknow($kid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DeleteKnowledge'
|
|
);
|
|
$data['KnowledgeId']=$kid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 - 发布
|
|
KnowledgeId Long 是 待删除知识id
|
|
*/
|
|
public function pushknow($kid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'PublishKnowledge'
|
|
);
|
|
$data['KnowledgeId']=$kid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 -失效
|
|
KnowledgeId Long 是 待删除知识id
|
|
*/
|
|
public function disableknow($kid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DisableKnowledge'
|
|
);
|
|
$data['KnowledgeId']=$kid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*知识库 - 知识 -转移类⽬
|
|
KnowledgeId Long 是 知识id
|
|
CategoryId Long 是 类⽬id
|
|
*/
|
|
public function moveknow($kid='',$cid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'MoveKnowledgeCategory'
|
|
);
|
|
$data['KnowledgeId']=$kid;
|
|
$data['CategoryId']=$cid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*机器⼈-创建
|
|
*Name String 是 机器⼈名称,不超过7 字
|
|
*Introduction String 否 机器⼈备注,不超过50 字
|
|
*LanguageCode String 是 机器⼈服务的语⾔,如 zh-cn、en-us77
|
|
TimeZone String 是 机器⼈的时区,参考 《公共-时区码》
|
|
RobotType String 否 机器⼈类型: scenario_im、 scenario_ivr、 scenario_callout
|
|
*/
|
|
public function createBot($name='',$intro='',$lang='zh-cn',$zone='',$type=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreateBot'
|
|
);
|
|
$data['Name']=$name;
|
|
if($intro)$data['Introduction']=$intro;
|
|
$data['LanguageCode']=$lang;
|
|
$data['TimeZone']=$zone;
|
|
if($type)$data['RobotType']=$type;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*机器⼈-详情
|
|
InstanceId String 是 机器⼈ID
|
|
*/
|
|
public function botDetail($iid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeBot'
|
|
);
|
|
$data['InstanceId']=$iid;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*机器⼈-列表
|
|
PageNumber Integer 否 分⻚-第⼏⻚,默认1
|
|
PageSize Integer 否 分⻚-⻚⾯⼤⼩,默认 10
|
|
*/
|
|
public function bots($page=1,$size=10){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryBots'
|
|
);
|
|
$data['PageNumber']=$page;
|
|
$data['PageSize']=$size;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话单元 - 列表
|
|
InstanceId String 是 机器⼈ ID
|
|
DialogName String 否 对话单元名称
|
|
*/
|
|
public function dialogs($iid='',$name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryDialogs'
|
|
);
|
|
$data['InstanceId']=$iid;
|
|
if($name)$data['DialogName']=$name;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话单元 - 详情
|
|
DialogId Long 是 对话 ID
|
|
*/
|
|
public function describedialog($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeDialog'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话单元 - 创建
|
|
InstanceId String 是 应⽤ ID
|
|
DialogName String 否 对话单元名称
|
|
Description String 否 对话单元描述
|
|
*/
|
|
public function createDialog($iid='',$name='',$des=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreateDialog'
|
|
);
|
|
$data['InstanceId']=$iid;
|
|
if($name)$data['DialogName']=$name;
|
|
if($des)$data['Description']=$des;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话单元 - 修改
|
|
DialogId Long 是 对话 ID
|
|
DialogName String 是 对话名称
|
|
Description String 否 对话描述
|
|
*/
|
|
public function updateDialog($did='',$name='',$des=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdateDialog'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data['DialogName']=$name;
|
|
if($des)$data['Description']=$des;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话单元 - 删除
|
|
DialogId Long 是 对话 ID
|
|
*/
|
|
public function delDialog($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DeleteDialog'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话流 - 保存草稿
|
|
DialogId Long 是 对话 ID
|
|
DialogFlowDefinition String 是 对话流描述信息(Json 字符串)
|
|
*/
|
|
public function updateFlow($did='',$flow=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdateDialogFlow'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$flow=json_encode($flow);
|
|
$data['DialogFlowDefinition']=$flow;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话流 - 测试
|
|
DialogId Long 是 对话 ID
|
|
*/
|
|
public function testFlow($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'TestDialogFlow'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话流 - 发布
|
|
DialogId Long 是 对话 ID
|
|
*/
|
|
public function pushFlow($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'PublishDialogFlow'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话流 - 下线
|
|
DialogId Long 是 对话 ID
|
|
*/
|
|
public function disableFlow($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DisableDialogFlow'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 对话流 - 详情
|
|
DialogId Long 是 对话 ID
|
|
*/
|
|
public function describeFlow($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeDialogFlow'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data= array_merge($params,$data);
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 意图 - 列表
|
|
DialogId Long 是 对话流Id
|
|
IntentName String 否 意图名称
|
|
PageNumber Integer 否 分⻚-第⼏⻚,默认1
|
|
PageSize Integer 否 分⻚-⻚⾯⼤⼩,默认 10
|
|
*/
|
|
public function intents($did='',$name='',$page=1,$size=10){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryIntents'
|
|
);
|
|
$data['DialogId']=$did;
|
|
if($name)$data['IntentName']=$name;
|
|
if($page)$data['PageNumber']=$page;
|
|
if($size)$data['PageSize']=$size;
|
|
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 意图 - 详情
|
|
IntentId Long 是 意图 ID
|
|
*/
|
|
public function describeIntent($iid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeIntent'
|
|
);
|
|
$data['IntentId']=$iid;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 意图 - 创建
|
|
DialogId Long 是 对话 ID
|
|
IntentDefinition JSON 是 意图描述信息-JSON字 符串,
|
|
|
|
IntentDefinition
|
|
IntentId Long 意图Id
|
|
Name String 意图名称
|
|
UserSay Array of UserSay 意图表述
|
|
RuleCheck Array of RuleCheck LGF意图表述表达式//TODO校 验
|
|
Slot Array of Slot 意图槽位信息
|
|
|
|
UserSay 字段名 类型 描述
|
|
Id String 表述唯⼀标识 UUID
|
|
Data Array of SayText 意图表述(被划词切分后结果)
|
|
Strict Boolean 是否严格匹配
|
|
SayText 字段名 类型 描述
|
|
SlotId String 槽位唯⼀标识
|
|
Text String 表述
|
|
RuleCheck 字段名 类型 描述
|
|
Warning Array of String 异常提示//TODO,可为空数组 Text String 表达式值
|
|
Strict Boolean 是否严格匹配
|
|
Error Array of String 错误提示//TODO,可为空数组
|
|
|
|
Slot
|
|
Id String 槽位唯⼀标识 UUID
|
|
Question Array of String 槽位反问话术,默认范⽂
|
|
LifeSpan Integer 槽位⽣命周期:默认0,可⾃定 义,建议5 //TODO,后台默认 0
|
|
Name String 槽位名称
|
|
IsArray Boolean 是否数组
|
|
Value String 槽位划词结果,对应“@${专有名 词名称}”,@是必须的
|
|
IsNecessary Boolean 是否必填槽
|
|
Tags Array of Tag 槽位划词标签
|
|
|
|
IntentDefinition(JSON):如下【注意:意图中 UseSay 需要带上 Id 字段,请⾃⾏⽣成 UUID】
|
|
TagUserSayId String 标签对应意图表述唯⼀标识
|
|
Value String 标签对应意图表述划词结果
|
|
*/
|
|
public function createIntent($did='',$intent=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreateIntent'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$intent=json_encode($intent);
|
|
$data['IntentDefinition']=$intent;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 意图 - 修改
|
|
IntentId Long 是 意图 ID
|
|
IntentDefinition JSON 是 ⻅意图描述信息
|
|
*/
|
|
public function editIntent($did='',$intent=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdateIntent'
|
|
);
|
|
$data['IntentId']=$did;
|
|
$intent=json_encode($intent);
|
|
$data['IntentDefinition']=$intent;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 意图 - 删除
|
|
IntentId Long 是 意图 ID
|
|
IntentDefinition JSON 是 ⻅意图描述信息
|
|
*/
|
|
public function delIntent($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DeleteIntent'
|
|
);
|
|
$data['IntentId']=$did;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 专有名词 - 列表
|
|
DialogId Long 是 对话单元Id
|
|
EntityName String 否 专有名词名称
|
|
PageNumber Integer 否 当前⻚,默认1
|
|
ageSize Integer 否 ⻚⾯⼤⼩,默认10
|
|
*/
|
|
public function entities($did='',$name='',$page=1,$size=10){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QueryEntities'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data['EntityName']=$name;
|
|
$data['PageNumber']=$page;
|
|
$data['ageSize']=$size;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 专有名词 - 详情
|
|
EntityId Long 是 专有名词id
|
|
*/
|
|
public function describeEntities($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DescribeEntities'
|
|
);
|
|
$data['EntityId']=$did;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 专有名词 - 创建
|
|
DialogId Long 是 对话 ID
|
|
EntityName String 是 专有名词名称
|
|
EntityType String 是 类型:regex:正则名 词;
|
|
synonyms:标准 名词 Regex String 否 正则表达式,与
|
|
Regex String 否 正则表达式,与 Members⼆选⼀必填
|
|
Members Array of Member 否 专有名词成员(json字符 串),与Regex⼆选⼀必 填
|
|
Members⼆选⼀必填 Members Array of Member 否 专有名词成员(json字符 串)
|
|
Synonyms Array Of String 否 成员同义词列表
|
|
MemberName String 是 成员名称
|
|
*/
|
|
public function createEntities($did='',$name='',$type='',$synon='',$regex='',$members=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'CreateEntity'
|
|
);
|
|
$data['DialogId']=$did;
|
|
$data['EntityName']=$name;
|
|
$data['EntityType']=$type;
|
|
$data['synonyms']=$synon;
|
|
$data['Regex']=$regex;
|
|
$data['Members']=json_encode($members);
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
*对话⼯⼚ - 专有名词 - 修改
|
|
EntityId Long 是 对话 ID
|
|
EntityName String 是 专有名词名称
|
|
EntityType String 是 类型:regex:正则名 词;
|
|
synonyms:标准 名词 Regex String 否 正则表达式,与
|
|
Regex String 否 正则表达式,与 Members⼆选⼀必填
|
|
Members Array of Member 否 专有名词成员(json字符 串),与Regex⼆选⼀必 填
|
|
Members⼆选⼀必填 Members Array of Member 否 专有名词成员(json字符 串)
|
|
Synonyms Array Of String 否 成员同义词列表
|
|
MemberName String 是 成员名称
|
|
*/
|
|
public function editEntities($did='',$name='',$type='',$synon='',$regex='',$members=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'UpdateEntity'
|
|
);
|
|
$data['EntityId']=$did;
|
|
$data['EntityName']=$name;
|
|
$data['EntityType']=$type;
|
|
$data['Regex']=$regex;
|
|
$data['Members']=json_encode($members);
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 对话⼯⼚ - 专有名词 - 删除
|
|
* @param string $did
|
|
* @return array
|
|
*/
|
|
public function delEntities($did=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'DeleteEntity'
|
|
);
|
|
$data['EntityId']=$did;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 对话⼯⼚ - 专有名词 - 追加
|
|
* EntityId Long 是 实体 ID
|
|
* ApplyType String 是 追加内容: memberName-专有名 词成员、synonyms-专 有名词相似问
|
|
* Member JSON 是 专有名词成员(json字符 串)
|
|
*/
|
|
public function appendMember($eid='',$type='',$member=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'AppendEntityMember'
|
|
);
|
|
$data['EntityId']=$eid;
|
|
$data['ApplyType']=$type;
|
|
$data['Member']=json_encode($member);
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 对话⼯⼚ - 专有名词 - 移除
|
|
* EntityId Long 是 实体 ID
|
|
* RemoveType String 是 追加内容: memberName-专有名 词成员、synonyms-专 有名词相似问
|
|
* Member JSON 是 专有名词成员(json字符 串)
|
|
*/
|
|
public function delMember($eid='',$type='',$member=[]){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'RemoveEntityMember'
|
|
);
|
|
$data['EntityId']=$eid;
|
|
$data['RemoveType']=$type;
|
|
$data['Member']=json_encode($member);
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 对话⼯⼚ - 专有名词 - 系统专有名词列表
|
|
* EntityName String 是 搜索系统专有名词关键 字
|
|
*/
|
|
public function sysEntities($name=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'QuerySystemEntities'
|
|
);
|
|
$data['EntityName']=$name;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 会话API
|
|
* InstanceId String 是 机器⼈实例ID。登录云 ⼩蜜控制台,左侧⾯板 选择开发者->基本配 置,查看机器⼈示例信 息,可获得该实例ID。
|
|
* Utterance String 是 机器⼈访问者的输⼊
|
|
* SessionId String 否 会话ID,⽤于标识⼀个 访问者的会话和保持上 下⽂信息。对于⼀个新 的访问者,⾸次调⽤ Chat接⼝时⽆需传递此 字段,机器⼈会开启⼀ 个会话,并在Chat接⼝ 的响应中返回该会话的 SessionId。对于该访 问者的后续轮次的会 话,调⽤Chat接⼝时传 递当前会话的 SessionId,机器⼈即 可基于SessionId继续 该轮次会话。
|
|
* KnowledgeId String 否 知识库词条的关联问题 的ID。若指定此ID,那 么机器⼈会直接返回指 定的关联问题指定视⻆ 的答案
|
|
* SenderId String 否 访问者ID。⽤于识别当 前会话中的⽤户
|
|
* SenderNick String 否 当前会话中访问的昵称
|
|
* Tag String 否 可以传递任何内容参 数,该参数将会直接在 返回结果中透传回来 (公有云)。
|
|
* PerspectivesList String 否 视⻆编码,⽤于调⽤同 ⼀知识标题下不同视⻆ 的答案。⽬前仅⽀持⼀ 个视⻆答案的调⽤,视 ⻆的请求格式是数组, ⽐如["default"] (URL 请求,请注意括号的转 义(Perspective=%5B"d efault"%5D))(私有云)
|
|
* Perspective.1 String 否 视⻆编码,⽤于调⽤同 ⼀知识标题下不同视⻆ 的答案。在拼装请求参 数时,需要以 Perspective.1={视⻆编 码}的格式传递参数。 如:&Perspective.1=FZJB Y3raWr。使⽤SDK时 以SDK中定义的参数为 准。⽬前仅⽀持⼀个视 ⻆答案的调⽤。 (公有云) Recommend Boolean 否 默认true,会话API保 持出推荐逻辑;如果
|
|
* recommend = false则 不出推荐
|
|
* RecommendNum Integer 否 推荐问题数量,1-10, 当出推荐的时候才⽣ 效,返回不⼤于
|
|
* RecommendNum的推 荐问题数量
|
|
*/
|
|
public function chat($iid='',$utter='',$sid='',$kid='',$sendid='',$snick='',$tag='',$plist='',$per='',$recom='',$rnum=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'Chat'
|
|
);
|
|
$data['InstanceId']=$iid;
|
|
$data['Utterance']=$utter;
|
|
if($sid)$data['SessionId']=$sid;
|
|
if($kid)$data['KnowledgeId']=$kid;
|
|
if($sendid)$data['SenderId']=$sendid;
|
|
if($snick)$data['SenderNick']=$snick;
|
|
if($tag)$data['Tag']=$tag;
|
|
if($plist)$data['PerspectivesList']=$plist;
|
|
if($per)$data['Perspective.1']=$per;
|
|
if($recom)$data['Recommend']=$recom;
|
|
if($rnum)$data['RecommendNum']=$rnum;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-指标数据
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function sessionData($stime='',$etime='',$rebotid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'GetBotSessionData'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-机器⼈对话轮次详情
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function chatData($stime='',$etime='',$rebotid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'GetBotChatData'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-机器⼈对话轮次详情
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function chatDetailData($stime='',$etime='',$rebotid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotReceptionDetailDatas'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-知识概览API
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botKnowledgeData($stime='',$etime='',$rebotid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'GetBotKnowledgeStatData'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-机器⼈热⻔知识
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botHotKnowledges($stime='',$etime='',$rebotid='',$limit=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotHotKnowledges'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data['Limit']=$limit;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-机器⼈冷⻔知识
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botColdKnowledges($stime='',$etime='',$rebotid='',$limit=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotColdKnowledges'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data['Limit']=$limit;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-机器⼈知识明细API
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botKnowledgeDetail($stime='',$etime='',$rebotid='',$limit=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotKnowledgeDetails'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data['Limit']=$limit;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-对话⼯⼚概览API
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botDsStat($stime='',$etime='',$rebotid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'GetBotDsStatData'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-对话流热⻔榜
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botHotDsDatas($stime='',$etime='',$rebotid='',$limit=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotHotDsDatas'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data['Limit']=$limit;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-对话流冷⻔榜
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botColdDsDatas($stime='',$etime='',$rebotid='',$limit=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotColdDsDatas'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data['Limit']=$limit;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-对话流明细
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botDsDetail($stime='',$etime='',$rebotid='',$limit=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotDsDetails'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data['Limit']=$limit;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**数据api-会话历史明细
|
|
* StartTime String 是 查询开始时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* EndTime String 是 查询结束时间,时间格式 为yyyyMMdd,⽐如 20190401
|
|
* RobotInstanceId String 是 机器⼈实例id
|
|
* @return array
|
|
*/
|
|
public function botChatHistorys($stime='',$etime='',$rebotid='',$limit=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListBotChatHistorys'
|
|
);
|
|
$data['StartTime']=$stime;
|
|
$data['EndTime']=$etime;
|
|
$data['RobotInstanceId']=$rebotid;
|
|
$data['Limit']=$limit;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**获取会话列表
|
|
* InstanceId String 是 机器⼈实例ID。登录云⼩蜜控 制台,左侧⾯板选择开发者-> 基本配置,查看机器⼈示例信 息,可获得该实例ID。
|
|
* SessionId String 否 会话ID,⽤于标识⼀个访问者 的会话和保持上下⽂信息。对 于⼀个新的访问者,⾸次调⽤ Chat接⼝时⽆需传递此字段, 机器⼈会开启⼀个会话,并在 Chat接⼝的响应中返回该会话 的SessionId。对于该访问者的 后续轮次的会话,调⽤Chat接 ⼝时传递当前会话的 SessionId,机器⼈即可基于 SessionId继续该轮次会话。
|
|
SenderId String 否 访问者ID。⽤于识别当前会话 中的⽤户。
|
|
StartDate String 否 开始时间。
|
|
EndDate String 否 结束时间。
|
|
PageNumber Integer 否 当前⻚码(默认1)。
|
|
PageSize Integer 否 每⻚条数(默认10),最⼤50。
|
|
* @return array
|
|
*/
|
|
public function conversationList($iid='',$sid='',$senderid='',$sdate='',$edate='',$page=1,$size=10){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'GetConversationList'
|
|
);
|
|
$data['InstanceId']=$iid;
|
|
if($sid)$data['SessionId']=$sid;
|
|
if($senderid)$data['SenderId']=$senderid;
|
|
if($sdate)$data['StartDate']=$sdate;
|
|
if($edate)$data['EndDate']=$edate;
|
|
if($page)$data['PageNumber']=$page;
|
|
if($size)$data['PageSize']=$size;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**获取会话详情
|
|
* InstanceId String 是 机器⼈实例ID。登录云⼩蜜控 制台,左侧⾯板选择开发者-> 基本配置,查看机器⼈示例信 息,可获得该实例ID。
|
|
* SessionId String 否 会话ID,⽤于标识⼀个访问者 的会话和保持上下⽂信息。对 于⼀个新的访问者,⾸次调⽤ Chat接⼝时⽆需传递此字段, 机器⼈会开启⼀个会话,并在 Chat接⼝的响应中返回该会话 的SessionId。对于该访问者的 后续轮次的会话,调⽤Chat接 ⼝时传递当前会话的 SessionId,机器⼈即可基于 SessionId继续该轮次会话。
|
|
SenderId String 否 访问者ID。⽤于识别当前会话 中的⽤户。
|
|
StartDate String 否 开始时间。
|
|
EndDate String 否 结束时间。
|
|
PageNumber Integer 否 当前⻚码(默认1)。
|
|
PageSize Integer 否 每⻚条数(默认10),最⼤50。
|
|
*/
|
|
public function listConverLogs($sid=''){
|
|
$params=$this->createdata();
|
|
$data = array(
|
|
// 接口参数
|
|
'Action' => 'ListConversationLogs'
|
|
);
|
|
$data['SessionId']=$sid;
|
|
$data= array_merge($params,$data);
|
|
|
|
$data['Signature'] = $this->computeSignature($data,$this->config['accessKeySecret']);
|
|
$data = $this->http($this->api, $data, $this->method);
|
|
return $data;
|
|
}
|
|
/**
|
|
* 发送HTTP请求方法,目前只支持CURL发送请求
|
|
* @param string $url 请求URL
|
|
* @param array $params 请求参数
|
|
* @param string $method 请求方法GET/POST
|
|
* @return array $data 响应数据
|
|
*/
|
|
protected function http($url, $params, $method = 'GET', $header = array(), $multi = false)
|
|
{
|
|
$opts = array(
|
|
CURLOPT_TIMEOUT => 30,
|
|
CURLOPT_RETURNTRANSFER => 1,
|
|
CURLOPT_SSL_VERIFYPEER => false,
|
|
CURLOPT_SSL_VERIFYHOST => false,
|
|
CURLOPT_HTTPHEADER => $header
|
|
);
|
|
|
|
/* 根据请求类型设置特定参数 */
|
|
switch (strtoupper($method)) {
|
|
case 'GET':
|
|
$opts[CURLOPT_URL] = $url . '?' . http_build_query($params);
|
|
break;
|
|
case 'POST':
|
|
//判断是否传输文件
|
|
$params = $multi ? $params : http_build_query($params);
|
|
$opts[CURLOPT_URL] = $url;
|
|
$opts[CURLOPT_POST] = 1;
|
|
$opts[CURLOPT_POSTFIELDS] = $params;
|
|
break;
|
|
default:
|
|
exception('不支持的请求方式!');
|
|
}
|
|
|
|
/* 初始化并执行curl请求 */
|
|
$ch = curl_init();
|
|
curl_setopt_array($ch, $opts);
|
|
$data = curl_exec($ch);
|
|
$error = curl_error($ch);
|
|
curl_close($ch);
|
|
if ($error)
|
|
exception('请求发生错误:' . $error);
|
|
return $data;
|
|
}
|
|
|
|
//生成取短信签名
|
|
private function computeSignature($parameters, $accessKeySecret)
|
|
{
|
|
ksort($parameters);
|
|
$canonicalizedQueryString = '';
|
|
foreach($parameters as $key => $value){
|
|
$canonicalizedQueryString .= '&' . $this->percentEncode($key). '=' . $this->percentEncode($value);
|
|
}
|
|
$stringToSign = $this->method.'&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1));
|
|
$signature = $this->signString($stringToSign, $accessKeySecret."&");
|
|
return $signature;
|
|
}
|
|
private function percentEncode($str)
|
|
{
|
|
$res = urlencode($str);
|
|
$res = preg_replace('/\+/', '%20', $res);
|
|
$res = preg_replace('/\*/', '%2A', $res);
|
|
$res = preg_replace('/%7E/', '~', $res);
|
|
return $res;
|
|
}
|
|
private function signString($source, $accessSecret)
|
|
{
|
|
return base64_encode(hash_hmac('sha1', $source, $accessSecret, true));
|
|
}
|
|
|
|
|
|
}
|