• 内容操作(旧)
    • 内容库
      • 获取内容库详情
      • 获取内容库列表
    • 内容分类
      • 获取内容分类详情
      • 获取内容分类列表
    • 内容
      • 获取内容详情
      • 获取内容列表

    内容操作(旧)

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

    内容库

    获取内容库详情

    接口

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

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

    代码示例

    {% tabs getGroupDetailCurl=”Curl”, getGroupDetailNode=”Node”, getGroupDetailPHP=”PHP” %}

    {% content “getGroupDetailCurl” %}

    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/

    {% content “getGroupDetailNode” %}

    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. })

    {% content “getGroupDetailPHP” %}

    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);

    {% endtabs %}

    返回示例

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

    获取内容库列表

    接口

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

    提交参数

    Content-Type: application/json

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

    代码示例

    {% tabs getLibraryCurl=”Curl”, getLibraryNode=”Node”, getLibraryPHP=”PHP” %}

    {% content “getLibraryCurl”%}

    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 “getLibraryNode” %}

    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. })

    {% content “getLibraryPHP”%}

    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);

    {% endtabs %}

    返回示例

    1. {
    2. "meta": {
    3. "limit": 10,
    4. "next": null,
    5. "offset": 0,
    6. "previous": null,
    7. "total_count": 1
    8. },
    9. "objects": [
    10. {
    11. "id": 1680,
    12. "name": "内容库 1"
    13. }
    14. ]
    15. }

    内容分类

    获取内容分类详情

    接口

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

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

    代码示例

    {% tabs getContentCategoryCurl=”Curl”, getContentCategoryNode=”Node”, getContentCategoryPHP=”PHP” %}

    {% content “getContentCategoryCurl”%}

    1. curl -X GET \
    2. -H "Authorization: Bearer token" \
    3. -H "Content-Type: application/json" \
    4. https://cloud.minapp.com/oserve/v1/content/category/:category_id/

    {% content “getContentCategoryNode” %}

    1. var request = require('request');
    2. var opt = {
    3. uri: 'https://cloud.minapp.com/oserve/v1/content/category/15130762527104xx/', // 15130762527104xx 对应 uri :category_id
    4. method: 'GET',
    5. headers: {
    6. Authorization: `Bearer ${token}`
    7. }
    8. }
    9. request(opt, function(err, res, body) {
    10. console.log(body)
    11. })

    {% content “getContentCategoryPHP”%}

    1. <?php
    2. $category_id = 1; // 对应内容分类 ID
    3. $url = "https://cloud.minapp.com/oserve/v1/content/category/{$category_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);

    {% endtabs %}

    返回示例

    1. {
    2. "id": 1680,
    3. "name": "分类 1",
    4. "has_children": true,
    5. "children": [
    6. {
    7. "has_children": false,
    8. "id": 1708,
    9. "name": "子分类"
    10. }
    11. ]
    12. }

    获取内容分类列表

    接口

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

    参数说明

    Content-Type: application/json

    参数 类型 必填 说明
    content_group_id String Y 内容库的 ID
    limit Number N 限制返回资源的个数,默认为 20 条,最大可设置为 1000
    offset Number N 设置返回资源的起始偏移值,默认为 0

    代码示例

    {% tabs getCategoryCurl=”Curl”, getCategoryNode=”Node”, getCategoryPHP=”PHP” %}

    {% content “getCategoryCurl” %}

    1. curl -X GET \
    2. -H "Authorization: Bearer token" \
    3. -H "Content-Type: application/json" \
    4. -G \
    5. -d order_by=-created_at \
    6. -d content_group_id=content_group_id \
    7. https://cloud.minapp.com/oserve/v1/content/category/?content_group_id=1

    {% content “getCategoryNode” %}

    1. var request = require('request');
    2. var opt = {
    3. uri: 'https://cloud.minapp.com/oserve/v1/content/category/',
    4. method: 'GET',
    5. headers: {
    6. Authorization: `Bearer ${token}`
    7. },
    8. qs: { // query string, 被附加到uri的参数
    9. content_group_id: '15130762111906xx'
    10. }
    11. }
    12. request(opt, function(err, res, body) {
    13. console.log(body)
    14. })

    {% content “getCategoryPHP”%}

    1. <?php
    2. $content_group_id = 1; // 内容库的 ID
    3. $url = "https://cloud.minapp.com/oserve/v1/content/category/?content_group_id={$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);

    {% endtabs %}

    返回示例

    1. {
    2. "meta": {
    3. "limit": 10,
    4. "next": null,
    5. "offset": 0,
    6. "previous": null,
    7. "total_count": 1
    8. },
    9. "objects": [
    10. {
    11. "id": 1680,
    12. "name": "分类 1",
    13. "has_children": true
    14. }
    15. ]
    16. }

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

    内容

    获取内容详情

    接口

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

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

    代码示例

    {% tabs getDetailCurl=”Curl”, getDetailNode=”Node”, getDetailPHP=”PHP” %}

    {% content “getDetailCurl”%}

    1. curl -X GET \
    2. -H "Authorization: Bearer token" \
    3. -H "Content-Type: application/json" \
    4. https://cloud.minapp.com/oserve/v1/content/detail/:content_id/

    {% content “getDetailNode”%}

    1. var request = require('request');
    2. var opt = {
    3. uri: 'https://cloud.minapp.com/oserve/v1/content/detail/15145144732272xx/', // 15145144732272xx 对应 uri :content_id
    4. method: 'GET',
    5. headers: {
    6. Authorization: `Bearer ${token}`
    7. }
    8. }
    9. request(opt, function(err, res, body) {
    10. console.log(body)
    11. })

    {% content “getDetailPHP”%}

    1. <?php
    2. $content_id = 1; // 内容库的 ID
    3. $url = "https://cloud.minapp.com/oserve/v1/content/detail/{$content_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);

    {% endtabs %}

    返回示例

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

    获取内容列表

    接口

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

    参数说明

    Content-Type: application/json

    参数 类型 必填 说明
    category_id String Y/N 内容分类的 ID
    content_group_id String Y/N 内容库的 ID
    order_by String N 对资源进行排序
    offset Number N 返回资源的起始偏移值)
    limit Number N 返回资源的个数(默认为 20,最大可设置为 1000

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

    排序

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

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

    示例:

    1. # 顺序
    2. https://cloud.minapp.com/oserve/v1/content/detail/?order_by=created_at
    3. # 倒序
    4. https://cloud.minapp.com/oserve/v1/content/detail/?order_by=-created_at

    代码示例

    {% tabs getContentCurl=”Curl”, getContentNode=”Node”, getContentPHP=”PHP” %}

    {% content “getContentCurl” %}

    1. curl -X GET \
    2. -H "Authorization: Bearer token" \
    3. -H "Content-Type: application/json" \
    4. -G \
    5. -d order_by=-created_at \
    6. -d category_id=category_id \
    7. https://cloud.minapp.com/oserve/v1/content/detail/?content_group_id=1

    {% content “getContentNode” %}

    1. var request = require('request');
    2. var opt = {
    3. uri: 'https://cloud.minapp.com/oserve/v1/content/detail/',
    4. method: 'GET',
    5. headers: {
    6. Authorization: `Bearer ${token}` // token的来源请看”授权认证”章节
    7. },
    8. qs: { // query string, 被附加到uri的参数
    9. content_group_id: '15130762111906xx',
    10. category_id: '15130762527104xx'
    11. }
    12. }
    13. request(opt, function(err, res, body) {
    14. console.log(body)
    15. })

    {% content “getContentPHP” %}

    1. <?php
    2. $content_group_id = 1; // 内容库的 ID
    3. $url = "https://cloud.minapp.com/oserve/v1/content/detail/?content_group_id={$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);

    {% endtabs %}

    返回示例

    1. {
    2. "meta": {
    3. "limit": 10,
    4. "next": null,
    5. "offset": 0,
    6. "previous": null,
    7. "total_count": 1
    8. },
    9. "objects": [
    10. {
    11. "content": "<p>\b 该片讲述了伊娅不满父亲的恶作剧</p>",
    12. "cover": "https://cloud-minapp-1131.cloud.ifanrusercontent.com/1donykIpnuvcRiAX.jpg",
    13. "created_at": 1504152062,
    14. "description": "超新约全书摘要",
    15. "id": 1680,
    16. "title": "超新约全书"
    17. }
    18. ]
    19. }