失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > api0.php API接口 · HisiPHP V2开发手册 · 看云

api0.php API接口 · HisiPHP V2开发手册 · 看云

时间:2022-06-13 20:23:49

相关推荐

api0.php API接口 · HisiPHP V2开发手册 · 看云

>[info] 快速导航

[TOC]

## 接口配置

在使用API之前你需要在后台做一个简单的API配置,如下图:

![](/e41db0b7698a94c70d6a8a1a47467fe4_1966x1264.png)

## 接口签名(sign)

>[info] 所有API接口调用必须要带签名参数sign

> 签名规则:md5(时间戳+API签名秘钥)

> 时间戳格式:yyyy-MM-dd HH:mm:ss

## [list] 内容列表

>[info]接口地址:/cms/api/list

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| cid | int/var | 是 | 0 | 分类ID,cid和mid最少传一个 |

| mid | int/var | 是 | 0 | 模型ID,cid和mid最少传一个 |

| orderby | string | 否 | id desc | 结果排序 |

| attr | string/array | 否 | | 扩展属性 |

| keyword | string/var | 否 | | 通过关键字搜索title |

| limit | int | 否 | 20 | 返回结果条数 |

| pagesize | int | 否 | 0 | 分页大小 |

| field | string | 否 | | 设置返回的字段 |

| flag | string | 否 | | 通过推荐旗帜筛选内容 |

| tag | string | 否 | | 通过标签筛选内容 |

| where | array | 否 | | 自定义查询条件 |

>[danger] 如果需要自定义where条件时,请使用POST方式请求此接口。

where格式:\[\['字段名1', '表达式', '值'\], \['字段名2', '表达式', '值'\]\]

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/list',

data: {

cid: 49,

pagesize: 20,

orderby: 'view desc',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'POST',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/list',

{

cid: 49,

pagesize: 20,

orderby: 'view desc',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [detail] 内容详情

>[info]接口地址:/cms/api/detail

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| id | int | 是 | | 内容ID |

>[info] 示例代码:

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/detail',

data: {

id: 49,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'POST',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/detail',

{

id: 49,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [category] 栏目列表

>[info]接口地址:/cms/api/category

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| cid | int/var | 是 | 0 | 分类ID,cid和mid最少传一个 |

| mid | int/var | 是 | 2 | 模型ID,cid和mid最少传一个 |

| level | int | 否 | 0 | 返回层级数,0为不限制 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/category',

data: {

cid: 49,

level: 3,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/category',

{

cid: 49,

level: 3,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [tag] 标签

>[info]接口地址:/cms/api/tag

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| mid | int/var| 是 | | 指定模型ID |

| orderby | string | 否 | search\_count desc | 排序 |

| limit | int | 否 | 10 | 限制返回数量 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/tag',

data: {

mid: 2,

limit: 15,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/tag',

{

mid: 2,

limit: 15,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [block] 碎片块

>[info]接口地址:/cms/api/block

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| name | string | 是 | | 碎片名称 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/block',

data: {

name: 'about',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/block',

{

name: 'about',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [nav] 导航

>[info]接口地址:/cms/api/nav

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| group | string | 否 | | 返回指定分组 |

| limit | int | 否 | 10 | 限制返回数量 |

| cache | bool | 否 | false | 缓存结果集 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/nav',

data: {

group: 'home',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/nav',

{

group: 'home',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [link] 友情链接

>[info]接口地址:/cms/api/link

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| type | string | 是 | | 类型,可选值:image,text,all |

| group | string | 否 | | 返回指定分组 |

| orderby | string | 否 | sort asc | 排序 |

| limit | int | 否 | 10 | 限制返回数量 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/link',

data: {

type: 'text',

group: 'home',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/link',

{

type: 'text',

group: 'home',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [slide] 幻灯片

>[info]接口地址:/cms/api/slide

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| type | string | 否 | pc | 类型,可选值:pc,wap |

| group | string | 否 | | 返回指定分组 |

| orderby | string | 否 | sort asc | 排序 |

| limit | int | 否 | 10 | 限制返回数量 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/slide',

data: {

type: 'wap',

group: 'home',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/slide',

{

type: 'wap',

group: 'home',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [rec] 推荐:rec

>[info]接口地址:/cms/api/rec

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| name | string | 是 | | 调用名称 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/rec',

data: {

name: 'product',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/rec',

{

name: 'product',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [type] 栏目类型

>[info]接口地址:/cms/api/type

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| tid | int | 是 | | 类型ID |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/type',

data: {

tid: 123,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/type',

{

tid: 123,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [form] 表单

>[info]接口地址:/cms/api/form

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| name | string | 是 | | 表单名称 |

>[info] 示例代码

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/form',

data: {

name: 'test',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'GET',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get(

'/cms/api/form',

{

name: 'test',

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

function(res) {

console.log(res);

}, 'json');

```

## [like] 喜欢/点赞

>[info]接口地址:/cms/api/like

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| id | int | 是 | | 内容ID |

>[info] 示例代码:

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/like',

data: {

id: 49,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'POST',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get('/cms/api/like', {

id: 49,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

}, function(res) {

console.log(res);

}, 'json');

```

## [dislike] 踩/不喜欢

>[info]接口地址:/cms/api/dislike

请求方式:GET/POST

| 属性名 | 类型 | 必须 | 默认 | 说明

| --- | --- | --- | --- | --- |

| id | int | 是 | | 内容ID |

>[info] 示例代码:

```

/* 微信小程序示例 */

wx.request({

url: '/cms/api/dislike',

data: {

id: 49,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

method: 'POST',

success: function (res) {

console.log(res);

}

});

/* jquery示例 */

$.get('/cms/api/dislike', {

id: 49,

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

}, function(res) {

console.log(res);

}, 'json');

```

## [batch] 批量获取接口数据

>[info]接口地址:/cms/api/batch

请求方式:POST

```

// 小程序请求示例

wx.request({

method: 'POST',

url: '/cms/api/batch',

data: {

// 接口名: {参数名: 参数值}

list: {cid: 1},// 请求内容列表接口

category: {cid: 0},// 请求分类接口

slide: {type: 'mini'},// 请求幻灯片接口

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

// 更多接口....

},

success:function(res) {

console.log(res)

}

});

// AJAX请求示例

$.ajax({

type: 'POST',

url: 'http://api./v1/articles',

data: {

// 接口名: {参数名: 参数值}

list: {cid: 1},// 请求内容列表接口

category: {cid: 0},// 请求分类接口

slide: {type: 'mini'},// 请求幻灯片接口

timestamp: '-05-01 12:12:12',// 时间戳

sign: 'cddb29f7db9647274fc604531ff82cea'// 签名

// 更多接口....

},

success: function(res) {

console.log(res)

}

});

```

>[warning] 上面示例代码的data对象里面的key就是需要获取的对应接口名(比如列表接口list,栏目接口category等等)

如果觉得《api0.php API接口 · HisiPHP V2开发手册 · 看云》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。