user->identity->username; $cert = fmFunc_cert_exist($username); $_FM['apiCert'] = $cert ? $cert : array(); $errorCode = 0; if($errorCode>0){ die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode)))); } $statusSite=[ '-1'=>'禁止', '0'=>'只读访问', '1'=>'正常', ]; //接口统计 $stat = fmFunc_stat_get($username); //错误代码集合 $errorcodes = require(Yii::getAlias('@common').'/messages/zh-CN/errorcode.php'); ?>
;
;
;
;
;
;
;
;
次;
次;
字节;
字节;
登陆地址: https://api.hiluker.com/index.php?r=oss/login&api=附加表单: 登陆数据以附加url转码后的字符串拼接到登陆地址中
$loginurl = https://api.hiluker.com/index.php?r=oss/login&api='.$_SERVER['HTTP_HOST'];
$post = array(
'LoginForm[username]' => 您的用户名,
'LoginForm[password]' => 您的密码,
'LoginForm[rememberMe]' => 1
);
foreach($post as $k => $v){
$loginurl .= '&'.urlencode($k).'='.urlencode($v);
}
成功返回: 登陆成功后,系统会返回一个accesstoken,通过json_decode解码即可。(随后所有的接口通讯都需要附加该accesstoken,所以建议您对该值进行存储,可以减少不必要的登陆连接)数据分类 主要分为POST数据与GET数据两类,其中部分限制约定数据必须从GET数据中取得,原则上POST进来的可以是任意类型、任意大小、任意长度的数据会直接被过滤掉的POST数据:这些数据会在传入时即被系统会自动过滤,不作任何保存操作
['id','siteid','createtime','updatetime','update_at'];
只允许GET方式的数据:这些数据与您的接口权限也有关联,在接口权限中有直接设定的,以设定好的数据为主
['uniacid','platid','shopid'];
SQL排序命令辅助sql_orders:传入方式为数组,键值顺序决定排列先后,每个元素本身也是一个数组,由排序字段及排序方式构成。DESC倒序,ASC升序
$post['sql_orders']=array(
"键"=>array(排序字段=》排序方式),
"1"=>array(”displayorder“=>"desc"),
"2"=>array(”id“=>"asc"),
……
);
SQL截断命令辅助sql_limits:传入方式为数组,数组内为起始位置、结束位置两个参数
$post['sql_limits']=array(
'start' => ($pindex-1)*$psize,
'end' => $psize,
);
SQL搜索命令辅助searching:传入方式为searching数组,内可包含['status','deleted','keyword','filter','plat']键
$post['searching']=array(
'status' => '', //指定状态(数据是否启用)(0,1)(默认1)
'deleted' => '', //指定状态(数据是否删除)(0,1)(默认0)
'keyword' => '', //指定要匹配的关键词(模糊检索,用以匹配标题项)
'filter' => array(要匹配的字段=》字段值) //用于设定数据过滤条件,并行条件(AND),精确匹配;支持多组(数组集,要匹配的字段=》字段值)($col=>$val),字段值可以是文本字符串(单一值)或二维数组(一个字段多种取值的情况)
'plat' => '', //指定跨平台搜索
);
注:SQL搜索命令辅助searching内如果还传入了其他参数,将由系统统一过滤整理,用作模糊匹配的可选条件(OR)
数据归类: 本站接口数据划分为三个层级——model(模型数据)=>instance(实例数据)=>content(内容数据)存取动作: 数据操作共三种——get(取数据列表)=>detail(取某组数据详情)=>save(保存数据)参数约定: (1) 控制器动作参数ac,action的简写,对应数据的层级归类,如 model或house或room。传入方式:GET(仅支持GET方法); (2) 控制器动作附加细分操作参数op,operation的简写,对应相应数据的操作,如 index或unused或deleted或all等。传入方式:GET(仅支持GET方法);
通常情况下,ac参数均只需用model或instance或content即可;部分接口模型(如realty房产模型)可能略有不同
op参数说明:'index': 取未删除、可用状态的数据;'unused': 取未删除、不可用状态的数据;'deleted':取已删除数据; 'all':取未删除数据;
返回结果:
对于get类的动作,返回数组,数组结构如下(仅为参考,实际可打印结果核实)
$return['errorcode'] = $errorCode; //正常情况下为0
$return['msg'] = Yii::t('errorcode',$errorCode); //返回的消息(接口报错时会使用到)
$return['data'] = isset($record) ? $record : ''; //用户侧应获得的数据
$return['timeused'] = getMillisecond() - $START_TIME; //接口耗时
$return['total'] = isset($count) ? $count : 1;//总记录数
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
对于detail类的动作,返回数组,结构如下:
$return['errorcode'] = $errorCode;
$return['msg'] = Yii::t('errorcode',$errorCode);
$return['data'] = isset($record) ? $record : '';
$return['timeused'] = getMillisecond() - $START_TIME;
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
对于save类的动作,返回数组,结构如下:
$return['errorcode'] = $errorCode;
$return['msg'] = Yii::t('errorcode',$errorCode);
$return['data'] = isset($record) ? $record : '';
$return['timeused'] = getMillisecond() - $START_TIME;
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
使用模型: realty所取数据: 客户侧指定的房产模型的下的楼盘实例(house)列表基础接口: https://api.hiluker.com/index.php?r=realty/get构建身份验证GET参数:
$getData = array();
$urlcondition1 = ’‘; //要附加到基础接口地址上的GET参数组
$getData['appid'] = $server['username']; //接口用户名
$getData['sceret'] = $server['code']; //接口密码
$getData['accesstoken'] = $AccessToken; //接口TOKEN
foreach($getData as $k => $v){
$urlcondition1 .= '&'. urlencode($k).'='. urlencode($v);
}
构建动作、操作等GET参数:
$getData = array();
$urlcondition2 = ’‘; //要附加到基础接口地址上的GET参数组
$getData['platid'] = '';
$getData['uniacid'] = '';
$getData['shopid'] = '';
$getData['ac'] = 'house';
$getData['op'] = 'all';
foreach($getData as $k => $v){
$urlcondition2 .= '&'. urlencode($k).'='. urlencode($v);
}
构建查询/筛选等POST参数:
$postData = array();
$postData['s_sn'] = $s_sn;
$postData['searching']['deleted'] = ''; //1或0;可选项,1为仅取用已删除数据
$postData['searching']['keyword'] = "; //可选项,关键词
$postData['searching']['status'] = ''; //1或0;可选项,1为仅取用已生效中的数据
$postData['searching']['plat'] = ''; //可选项,跨平台时使用
$postData['sql_limits'] = array(
'start' => 起始页位置,
'end' => 结束页位置,
);
//处理POST数据
foreach($postData as $k => &$v){
$v = json_encode($v); //(POST的数据各键值需是string文本类型)
}
发送请求