组集操作

获取组集详情

接口

GET https://cloud.minapp.com/oserve/v1/user-supergroup/:group_id/

其中 :group_id 需替换为你的用户组 ID

代码示例

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

{% content “getDetailCurl” %}

  1. curl -X GET \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v1/user-supergroup/52/

{% content “getDetailNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/666', // 666 对应 :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 “getDetailPHP”%}

  1. <?php
  2. $group_id = 1; // 用户组 ID
  3. $url = "https://cloud.minapp.com/oserve/v1/user-supergroup/{$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. "children": [
  3. {
  4. "id": 51,
  5. "name": "User Group"
  6. }
  7. ],
  8. "id": 52,
  9. "name": "Super Group"
  10. }

获取组集列表

接口

GET https://cloud.minapp.com/oserve/v1/user-supergroup/

参数说明

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

代码示例

{% tabs getCurl=”Curl”, getNode=”Node”, getPHP=”PHP” %}

{% content “getCurl” %}

  1. curl -X GET \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. -G \
  5. https://cloud.minapp.com/oserve/v1/user-supergroup/

{% content “getNode” %}

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

{% content “getPHP”%}

  1. <?php
  2. $url = 'https://cloud.minapp.com/oserve/v1/user-supergroup/';
  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 %}

创建组集

接口

POST https://cloud.minapp.com/oserve/v1/user-supergroup/

参数说明

Content-Type: application/json

参数 类型 必填 说明
name String Y 组集的名称
children String N 用户组 ID 列表

代码示例

{% tabs createCurl=”Curl”, createNode=”Node”, createPHP=”PHP” %}

{% content “createCurl” %}

  1. curl -X POST \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. -d '{"name": "Super Group", "children": [51]}' \
  5. https://cloud.minapp.com/oserve/v1/user-supergroup/

{% content “createNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/',
  4. method: 'POST',
  5. headers: {
  6. Authorization: `Bearer ${token}`,
  7. },
  8. json: { // 指定 data 以 "Content-Type": 'application/json' 传送
  9. name: 'super group',
  10. children: [561]
  11. }
  12. }
  13. request(opt, function(err, res, body) {
  14. console.log(res.statusCode)
  15. })

{% content “createPHP” %}

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

{% endtabs %}

状态码说明

201 写入成功

修改组集

danger
该接口会清除掉旧有的组集和用户组的关系,重新与传入的用户组建立关系

接口

PUT https://cloud.minapp.com/oserve/v1/user-supergroup/:group_id/

其中 :group_id 需替换为你的用户组 ID

状态码说明

200 修改成功

代码示例

{% tabs updateCurl=”Curl”, updateNode=”Node”, updatePHP=”PHP” %}

{% content “updateCurl” %}

  1. curl -X PUT \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. -d '{"name": "super group 3", "children": [51]}' \
  5. https://cloud.minapp.com/oserve/v1/user-supergroup/52/

{% content “updateNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/666/', // 665 对应 :group_id
  4. method: 'PUT',
  5. headers: {
  6. Authorization: `Bearer ${token}`,
  7. },
  8. json: { // 指定 data 以 "Content-Type": 'application/json' 传送
  9. name: 'super group',
  10. children: [561]
  11. }
  12. }
  13. request(opt, function(err, res, body) {
  14. console.log(res.statusCode, body)
  15. })

{% content “updatePHP” %}

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

{% endtabs %}

返回示例

  1. {
  2. "children": [
  3. {
  4. "id": 51,
  5. "name": "User Group"
  6. }
  7. ],
  8. "id": 52,
  9. "name": "super group 3"
  10. }

删除组集

接口

DELETE https://cloud.minapp.com/oserve/v1/user-supergroup/:group_id/

代码示例

{% tabs deleteCurl=”Curl”, deleteNode=”Node”, deletePHP=”PHP” %}

{% content “deleteCurl” %}

  1. curl -X DELETE \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v1/user-supergroup/52/

{% content “deleteNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/666/', // 666 对应 :group_id
  4. method: 'DELETE',
  5. headers: {
  6. Authorization: `Bearer ${token}`,
  7. }
  8. }
  9. request(opt, function(err, res, body) {
  10. console.log(res.statusCode)
  11. })

{% content “deletePHP” %}

  1. <?php
  2. $group_id = 52; // 用户组 ID
  3. $url = "https://cloud.minapp.com/oserve/v1/user-supergroup/{$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 删除成功

批量删除组集

接口

DELETE https://cloud.minapp.com/oserve/v1/user-supergroup/?id__in=:group_id,group1_id

代码示例

{% tabs patchDeleteCurl=”Curl”, patchDeleteNode=”Node”, patchDeletePHP=”PHP” %}

{% content “patchDeleteCurl” %}

  1. curl -X DELETE \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v1/user-supergroup/?id__in=58,56

{% content “patchDeleteNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/?id__in=667,668', // id__in=:667,668 对应 id__in=:group_id,group1_id
  4. method: 'DELETE',
  5. headers: {
  6. Authorization: `Bearer ${token}`,
  7. }
  8. }
  9. request(opt, function(err, res, body) {
  10. console.log(res.statusCode)
  11. })

{% content “patchDeletePHP” %}

  1. <?php
  2. // 用户组 ID 集
  3. $group_id[] = 56;
  4. $group_id[] = 58;
  5. $url = "https://cloud.minapp.com/oserve/v1/user-supergroup/?id__in=".implode(',',$group_id);
  6. $ch = curl_init();
  7. $header = array(
  8. "Authorization: Bearer {$token}",
  9. 'Content-Type: application/json; charset=utf-8'
  10. );
  11. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  12. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  13. curl_setopt($ch, CURLOPT_URL, $url);
  14. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
  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 %}

状态码说明

204 删除成功