漏刻有时开放平台,提供强大且智能的API接口,LockDataAPI-SDK ,文件位于根目录api目录下,包含:
- 1.LockData.php,核心数据读取,json展示代码对象封装页面;
- 2.api.php,数据授权读取接口;
API接口代码:
public function sales() { global $db, $res; dbc(); $row = $db->queryall("select vname,vdata,vtask,Round(vdata/vtask*100,2) as totalrate from " . $db->table('demo')); $res["data"] = $row; die(json_encode_lockdata($res)); }
api前端调用:
http://test.com/api/api.php?act=getToday&token=3cab7ce4142608c0f40c785b5ab5ca24
json结构:
{"err":"","res":"","data":[{"totalPays":"97674.45"}]}
为了和layui框架无缝集合,预计会新增加JSON字段。
{"code":0,"msg:"",count:"30",err":"","res":"","data":[{"totalPays":"97674.45"}]}
Done!