内容模块 - 内容库操作

优质
小牛编辑
139浏览
2023-12-01

获取内容库详情

接口

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

其中 content_group_id 是内容库的 ID

代码示例

{% tabs getContentGroupCurl=”Curl”, getContentGroupNode=”Node”, getContentGroupPHP=”PHP” %}

{% content “getContentGroupCurl” %}

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

{% content “getContentGroupNode” %}

  1. var request = require("request");
  2. var options = { method: 'GET',
  3. url: 'https://cloud.minapp.com/oserve/v1/content/1/',
  4. headers:
  5. { 'Content-Type': 'application/json',
  6. Authorization: 'Bearer cfb5912724dd7ff0b0c17683cc3074bb548bc7f4' } };
  7. request(options, function (error, response, body) {
  8. if (error) throw new Error(error);
  9. console.log(body);
  10. });

{% content “getContentGroupPHP” %}

  1. <?php
  2. $content_group_id = 1; // 内容库的 ID
  3. $url = "https://cloud.minapp.com/oserve/v1/content/{$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": 1,
  3. "name": "内容库",
  4. "acl_gids": [],
  5. "created_at": 1489137188,
  6. "updated_at": 1495769882
  7. }

获取内容库列表

接口

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

提交参数

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

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

    https://cloud.minapp.com/oserve/v1/content/?name=内容库1

代码示例

{% tabs getContentGroupListCurl=”Curl”, getContentGroupListNode=”Node”, getContentGroupListPHP=”PHP” %}

{% content “getContentGroupListCurl” %}

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

{% content “getContentGroupListNode” %}

  1. var request = require("request");
  2. var options = { method: 'GET',
  3. url: 'https://cloud.minapp.com/oserve/v1/content/',
  4. headers:
  5. { 'Content-Type': 'application/json',
  6. Authorization: 'Bearer cfb5912724dd7ff0b0c17683cc3074bb548bc7f4' } };
  7. request(options, function (error, response, body) {
  8. if (error) throw new Error(error);
  9. console.log(body);
  10. });

{% content “getContentGroupListPHP” %}

  1. <?php
  2. $url = "https://cloud.minapp.com/oserve/v1/content/";
  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": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 1
  8. },
  9. "objects": [
  10. {
  11. "id": 1,
  12. "name": "内容库",
  13. "acl_gids": [],
  14. "created_at": 1489137188,
  15. "updated_at": 1495769882
  16. }
  17. ]
  18. }

创建内容库

接口

POST https://cloud.minapp.com/oserve/v1/content/

参数说明

Content-Type: application/json

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

代码示例

{% tabs createContentGroupCurl=”Curl”, createContentGroupNode=”Node”, createContentGroupPHP=”PHP” %}

{% content “createContentGroupCurl” %}

  1. curl -X POST \
  2. -H "Authorization: Bearer cfb5912724dd7ff0b0c17683cc3074bb548bc7f4" \
  3. -H "Content-Type: application/json" \
  4. -d '{
  5. "name": "Content Group",
  6. "acl_gids": [1, 2]
  7. }' \
  8. https://cloud.minapp.com/oserve/v1/content/

{% content “createContentGroupNode” %}

  1. var request = require("request");
  2. var options = { method: 'POST',
  3. url: 'https://cloud.minapp.com/oserve/v1/content/',
  4. headers:
  5. { 'Content-Type': 'application/json',
  6. Authorization: 'Bearer cfb5912724dd7ff0b0c17683cc3074bb548bc7f4' },
  7. body: { name: 'Content Group', acl_gids: [ 1, 2 ] },
  8. json: true };
  9. request(options, function (error, response, body) {
  10. if (error) throw new Error(error);
  11. console.log(body);
  12. });

{% content “createContentGroupPHP” %}

  1. <?php
  2. $param['name'] = 'CreateContentGroup';
  3. $param['acl_gids'] = [1, 2];
  4. $url = 'https://cloud.minapp.com/oserve/v1/content/';
  5. $ch = curl_init();
  6. $header = array(
  7. "Authorization: Bearer {$token}",
  8. 'Content-Type: application/json; charset=utf-8'
  9. );
  10. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  11. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  12. curl_setopt($ch, CURLOPT_URL, $url);
  13. curl_setopt($ch, CURLOPT_POST, true);
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  17. $res['response'] = curl_exec($ch); // 反馈结果
  18. $res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
  19. curl_close($ch);

{% endtabs %}

返回示例

  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/oserve/v1/content/:content_group_id/

代码示例

{% tabs updateContentGroupCurl=”Curl”, updateContentGroupNode=”Node”, updateContentGroupPHP=”PHP” %}

{% content “updateContentGroupCurl” %}

  1. curl -X PUT \
  2. -H "Authorization: Bearer cfb5912724dd7ff0b0c17683cc3074bb548bc7f4" \
  3. -H "Content-Type: application/json" \
  4. -d '{
  5. "name": "Test Group"
  6. }' \
  7. https://cloud.minapp.com/oserve/v1/content/2/

{% content “updateContentGroupNode” %}

  1. var request = require("request");
  2. var options = { method: 'PUT',
  3. url: 'https://cloud.minapp.com/oserve/v1/content/2/',
  4. headers:
  5. { 'Content-Type': 'application/json',
  6. Authorization: 'Bearer cfb5912724dd7ff0b0c17683cc3074bb548bc7f4' },
  7. body: { name: 'Test Group' },
  8. json: true };
  9. request(options, function (error, response, body) {
  10. if (error) throw new Error(error);
  11. console.log(body);
  12. });

{% content “updateContentGroupPHP” %}

  1. <?php
  2. $content_group_id = 1; // 内容库的 ID
  3. $url = "https://cloud.minapp.com/oserve/v1/content/{$content_group_id}/";
  4. $param['name'] = 'UpdateContentGroup';
  5. $ch = curl_init();
  6. $header = array(
  7. "Authorization: Bearer {$token}",
  8. 'Content-Type: application/json; charset=utf-8'
  9. );
  10. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  11. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  12. curl_setopt($ch, CURLOPT_URL, $url);
  13. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  17. $res['response'] = curl_exec($ch); // 反馈结果
  18. $res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
  19. curl_close($ch);

{% endtabs %}

返回示例

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

状态码说明

200: 修改成功

400: 用户组 ID 不合法

删除内容库

接口

DELETE https://cloud.minapp.com/oserve/v1/content/:content_group_id/

代码示例

{% tabs deleteContentGroupCurl=”Curl”, deleteContentGroupNode=”Node”, deleteContentGroupPHP=”PHP” %}

{% content “deleteContentGroupCurl” %}

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

{% content “deleteContentGroupNode” %}

  1. var request = require("request");
  2. var options = { method: 'DELETE',
  3. url: 'https://cloud.minapp.com/oserve/v1/content/2/',
  4. headers:
  5. { 'Content-Type': 'application/json',
  6. Authorization: 'Bearer cfb5912724dd7ff0b0c17683cc3074bb548bc7f4' } };
  7. request(options, function (error, response, body) {
  8. if (error) throw new Error(error);
  9. console.log(body);
  10. });

{% content “deleteContentGroupPHP” %}

  1. <?php
  2. $content_group_id = 1; // 内容库的 ID
  3. $url = "https://cloud.minapp.com/oserve/v1/content/{$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, 'DELETE');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. $res['response'] = curl_exec($ch); // 反馈结果
  16. $res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
  17. curl_close($ch);

{% endtabs %}

状态码说明

204: 删除成功