内容库操作

获取内容库详情

接口

GET https://cloud.minapp.com/userve/v2.2/content/:content_group_id/

其中 content_group_id 是内容库的 ID

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.get('https://cloud.minapp.com/userve/v2.2/content/1/').then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "id": 1,
  3. "name": "内容库",
  4. "acl_gids": [],
  5. "anonymous_read": true,
  6. "created_at": 1489137188,
  7. "updated_at": 1495769882
  8. }

获取内容库列表

接口

GET https://cloud.minapp.com/userve/v2.2/content/

提交参数

  • name 内容库名称等值查询查询

例:查询内容库名称为 "内容库1" 的内容库

https://cloud.minapp.com/userve/v2.2/content/?name=内容库1

  • return_total_count 指定是否在 meta 中返回 total_count

例:指定返回 total_count

https://cloud.minapp.com/userve/v2.2/content/?return_total_count=1

若开发者只需要获取对象总数,则可以通过设置 limit=1 以及 return_total_count=1 来达到该效果,total_count 可从返回的 meta 中获取

请求示例:

  1. https://cloud.minapp.com/userve/v2.2/content/?limit=1&return_total_count=1

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.get('https://cloud.minapp.com/userve/v2.2/content/',{
  5. params: {
  6. name: '内容库1'
  7. }
  8. }).then(res => {
  9. console.log(res.data)
  10. })

返回示例

  1. {
  2. "meta": {
  3. "limit": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 1
  8. },
  9. "objects": [
  10. {
  11. "id": 1,
  12. "name": "内容库1",
  13. "acl_gids": [],
  14. "anonymous_read": false,
  15. "created_at": 1489137188,
  16. "updated_at": 1495769882
  17. }
  18. ]
  19. }

创建内容库

接口

POST https://cloud.minapp.com/userve/v2.2/content/

参数说明

Content-Type: application/json

参数类型必填说明
nameStringY内容库名称
acl_gidsInteger ArrayN用户的访问权限,其内为分组 ID
anonymous_readBooleanN是否允许匿名读

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.post('https://cloud.minapp.com/userve/v2.2/content/', {
  5. "name": "Content Group",
  6. "acl_gids": [1, 2]
  7. }).then(res => {
  8. console.log(res.data)
  9. })

返回示例

  1. {
  2. "id": 2,
  3. "name": "Content Group",
  4. "acl_gids": [1, 2],
  5. "created_at": 1489137188,
  6. "updated_at": 1495769882
  7. }

状态码说明

201: 创建成功

400: 用户组 ID 不合法

编辑内容库

接口

PUT https://cloud.minapp.com/userve/v2.2/content/:content_group_id/

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.put('https://cloud.minapp.com/userve/v2.2/content/2/', {
  5. "name": "Test Group"
  6. }).then(res => {
  7. console.log(res.data)
  8. })

返回示例

  1. {
  2. "id": 2,
  3. "name": "Test Group",
  4. "acl_gids": [1, 2],
  5. "anonymous_read": false,
  6. "created_at": 1489137188,
  7. "updated_at": 1495769882
  8. }

状态码说明

200: 修改成功

400: 用户组 ID 不合法

删除内容库

接口

DELETE https://cloud.minapp.com/userve/v2.2/content/:content_group_id/

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.delete('https://cloud.minapp.com/userve/v2.2/content/2/').then(res => {
  5. console.log(res.data)
  6. })

状态码说明

204: 删除成功