内容操作(旧)

以下操作不支持内容表自定义字段的获取,建议使用最新内容操作接口。

内容库

获取内容库详情

接口

GET https://cloud.minapp.com/oserve/v1/content/group/:content_group_id/

其中 :content_group_id 需替换为你的内容库 ID

代码示例

  1. curl -X GET \
  2. -H "Authorization: Bearer token" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v1/content/group/:content_group_id/
  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/content/group/15130762111906xx/', // 15130762111906xx 对应 uri :content_group_id
  4. method: 'GET',
  5. headers: {
  6. Authorization: `Bearer ${token}`
  7. }
  8. }
  9. request(opt, function(err, res, body) {
  10. console.log(body)
  11. })
  1. <?php
  2. $content_group_id = 1; // 内容库 ID
  3. $url = "https://cloud.minapp.com/oserve/v1/content/group/{$content_group_id}/";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. $res = curl_exec($ch);
  16. curl_close($ch);

返回示例

  1. {
  2. "id": 1680,
  3. "name": "内容库 1"
  4. }

获取内容库列表

接口

GET https://cloud.minapp.com/oserve/v1/content/group/

提交参数

Content-Type: application/json

参数类型必填说明
limitNumberN限制返回资源的个数,默认为 20 条,最大可设置为 1000
offsetNumberN设置返回资源的起始偏移值,默认为 0

代码示例

  1. curl -X GET \
  2. -H "Authorization: Bearer token" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v1/content/group/
  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/content/group/',
  4. method: 'GET',
  5. headers: {
  6. Authorization: `Bearer ${token}`
  7. },
  8. qs: { // query string, 被附加到uri的参数
  9. offset: 0, // 可选
  10. limit: 20 // 可选
  11. }
  12. }
  13. request(opt, function(err, res, body) {
  14. console.log(body)
  15. })
  1. <?php
  2. $url = "https://cloud.minapp.com/oserve/v1/content/group/";
  3. $ch = curl_init();
  4. $header = array(
  5. "Authorization: Bearer {$token}",
  6. 'Content-Type: application/json; charset=utf-8'
  7. );
  8. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  9. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  10. curl_setopt($ch, CURLOPT_URL, $url);
  11. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  14. $res = curl_exec($ch);
  15. curl_close($ch);

返回示例

{
  "meta": {
    "limit": 10,
    "next": null,
    "offset": 0,
    "previous": null,
    "total_count": 1
  },
  "objects": [
    {
      "id": 1680,
      "name": "内容库 1"
    }
  ]
}

内容分类

获取内容分类详情

接口

GET https://cloud.minapp.com/oserve/v1/content/category/:category_id/

其中 :category_id 需替换为你的内容分类 ID

代码示例

curl -X GET \
-H "Authorization: Bearer token" \
-H "Content-Type: application/json" \
https://cloud.minapp.com/oserve/v1/content/category/:category_id/
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/content/category/15130762527104xx/',  // 15130762527104xx 对应 uri :category_id
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`
  }
}

request(opt, function(err, res, body) {
    console.log(body)
})
<?php
$category_id = 1; // 对应内容分类 ID 
$url = "https://cloud.minapp.com/oserve/v1/content/category/{$category_id}/";

$ch = curl_init();
$header = array(
  "Authorization: Bearer {$token}",
  'Content-Type: application/json; charset=utf-8'
);

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res = curl_exec($ch);
curl_close($ch);

返回示例

{
  "id": 1680,
  "name": "分类 1",
  "has_children": true,
  "children": [
    {
      "has_children": false,
      "id": 1708,
      "name": "子分类"
    }
  ]
}

获取内容分类列表

接口

GET https://cloud.minapp.com/oserve/v1/content/category/

参数说明

Content-Type: application/json

参数类型必填说明
content_group_idStringY内容库的 ID
limitNumberN限制返回资源的个数,默认为 20 条,最大可设置为 1000
offsetNumberN设置返回资源的起始偏移值,默认为 0

代码示例

curl -X GET \
-H "Authorization: Bearer token" \
-H "Content-Type: application/json" \
-G \
-d order_by=-created_at \
-d content_group_id=content_group_id \
https://cloud.minapp.com/oserve/v1/content/category/?content_group_id=1
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/content/category/',
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`
  },
  qs: {     // query string, 被附加到uri的参数
    content_group_id: '15130762111906xx'
  }
}

request(opt, function(err, res, body) {
  console.log(body)
})
<?php
$content_group_id = 1; // 内容库的 ID 
$url = "https://cloud.minapp.com/oserve/v1/content/category/?content_group_id={$content_group_id}";

$ch = curl_init();
$header = array(
  "Authorization: Bearer {$token}",
  'Content-Type: application/json; charset=utf-8'
);

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res = curl_exec($ch);
curl_close($ch);

返回示例

{
  "meta": {
    "limit": 10,
    "next": null,
    "offset": 0,
    "previous": null,
    "total_count": 1
  },
  "objects": [
    {
      "id": 1680,
      "name": "分类 1",
      "has_children": true
    }
  ]
}

has_children 表示该分类是否包含子分类,通过获取内容分类详情接口可获得子分类的内容。

内容

获取内容详情

接口

GET https://cloud.minapp.com/oserve/v1/content/detail/:content_id/

其中 :content_id 需替换为你的内容 ID

代码示例

curl -X GET \
-H "Authorization: Bearer token" \
-H "Content-Type: application/json" \
https://cloud.minapp.com/oserve/v1/content/detail/:content_id/
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/content/detail/15145144732272xx/', // 15145144732272xx 对应 uri :content_id
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`
  }
}

request(opt, function(err, res, body) {
    console.log(body)
})
<?php
$content_id = 1; // 内容库的 ID 
$url = "https://cloud.minapp.com/oserve/v1/content/detail/{$content_id}/";

$ch = curl_init();
$header = array(
  "Authorization: Bearer {$token}",
  'Content-Type: application/json; charset=utf-8'
);

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res = curl_exec($ch);
curl_close($ch);

返回示例

{
  "content": "<p>\b 该片讲述了伊娅不满父亲的恶作剧</p>",
  "cover": "https://cloud-minapp-1131.cloud.ifanrusercontent.com/1donykIpnuvcRiAX.jpg",
  "created_at": 1504152062,
  "description": "超新约全书摘要",
  "id": 1680,
  "title": "超新约全书"
}

获取内容列表

接口

GET https://cloud.minapp.com/oserve/v1/content/detail/

参数说明

Content-Type: application/json

参数类型必填说明
categoryidStringY/N内容分类的 ID
content_group_idStringY/N内容库的 ID
order_byStringN对资源进行排序
offsetNumberN返回资源的起始偏移值)
limitNumberN返回资源的个数(默认为 _20,最大可设置为 1000

注意:发起请求时需要携带 category_idcontent_group_id 参数。

排序

接口支持以 created_at 字段进行排序,默认是以创建时间的顺序进行排序。

通过提交 order_by 参数来更改接口的排序;

示例:

# 顺序
https://cloud.minapp.com/oserve/v1/content/detail/?order_by=created_at

# 倒序
https://cloud.minapp.com/oserve/v1/content/detail/?order_by=-created_at

代码示例

curl -X GET \
-H "Authorization: Bearer token" \
-H "Content-Type: application/json" \
-G \
-d order_by=-created_at \
-d category_id=category_id \
https://cloud.minapp.com/oserve/v1/content/detail/?content_group_id=1
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/content/detail/',
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`  // token的来源请看”授权认证”章节
  },
  qs: {     // query string, 被附加到uri的参数
    content_group_id: '15130762111906xx',
    category_id: '15130762527104xx'
  }
}

request(opt, function(err, res, body) {
    console.log(body)
})
<?php
$content_group_id = 1; // 内容库的 ID
$url = "https://cloud.minapp.com/oserve/v1/content/detail/?content_group_id={$content_group_id}";

$ch = curl_init();
$header = array(
  "Authorization: Bearer {$token}",
  'Content-Type: application/json; charset=utf-8'
);

curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res = curl_exec($ch);
curl_close($ch);

返回示例

{
  "meta": {
    "limit": 10,
    "next": null,
    "offset": 0,
    "previous": null,
    "total_count": 1
  },
  "objects": [
    {
      "content": "<p>\b 该片讲述了伊娅不满父亲的恶作剧</p>",
      "cover": "https://cloud-minapp-1131.cloud.ifanrusercontent.com/1donykIpnuvcRiAX.jpg",
      "created_at": 1504152062,
      "description": "超新约全书摘要",
      "id": 1680,
      "title": "超新约全书"
    }
  ]
}