【发布时间】:2019-07-23 03:01:31
【问题描述】:
我正在编写如下的zabbix监控API。
{
"jsonrpc": "2.0",
"method": "data.delete",
"params":{
"startTimestamp": "1560725284",
"endTimestamp": "1560725644",
"deleteType": "0"
},
"auth": "6a810d97a79ef6d31ddde7bf93103299",
"id": 1
}
我创建了 CData.php api 服务并编写了函数 delete() 如下:
public function delete($startTimestamp, $endTimestamp, $deleteType) {
$from = zbx_toArray($startTimestamp);
$to = zbx_toArray($endTimestamp);
$type = zbx_toArray($deleteType);
// delete action conditions
$sql = 'delete from history where clock >='.$from.' and clock <= '.$to;
DBexecute($sql);
return ['success' => '200', 'message' => 'Đã xóa thành công', 'startTimestamp' => $from, 'endTimestamp' => $to, 'deleteType' =>$type];
}
当我以 get 方法调用 API 时出现问题: CLocalApiClient.php 第 123 行 $result = call_user_func_array([$this->serviceFactory->getObject($api), $method], [$params]);
和函数 CLocalApiClient->callMethod( ???, ???, ???, ??? )
CData->delete(???, ???, ???)上的CData服务错误
当我尝试以下代码时,它运行良好。
public function delete() {
$from = "1563229215";
$to = "1563229275";
$type = "0";
// delete action conditions
$sql = 'delete from history where clock >='.$from.' and clock <= '.$to;
DBexecute($sql);
return ['success' => '200', 'message' => 'Đã xóa thành công', 'startTimestamp' => $from, 'endTimestamp' => $to, 'deleteType' =>$type];
}
请帮助我如何将参数传递给 api 函数?
非常感谢, BienHV
【问题讨论】: