组集操作

获取组集详情

接口

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

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

代码示例

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

返回示例

  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/

参数说明

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

代码示例

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

创建组集

接口

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

参数说明

Content-Type: application/json

参数类型必填说明
nameStringY组集的名称
childrenStringN用户组 ID 列表

代码示例

curl -X POST \
-H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
-H "Content-Type: application/json" \
-d '{"name": "Super Group", "children": [51]}' \
https://cloud.minapp.com/oserve/v1/user-supergroup/
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/',
  method: 'POST',
  headers: {
    Authorization: `Bearer ${token}`,
  },
  json: {   // 指定 data 以 "Content-Type": 'application/json' 传送
    name: 'super group',
    children: [561]
  }
}

request(opt, function(err, res, body) {
  console.log(res.statusCode)
})
<?php
$param = array(
  'name' =>'Super Group',
  'children' => [51]
);
$url = 'https://cloud.minapp.com/oserve/v1/user-supergroup/';

$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_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res['response'] = curl_exec($ch); // 反馈结果
$res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
curl_close($ch);

状态码说明

201 写入成功

修改组集

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

接口

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

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

状态码说明

200 修改成功

代码示例

curl -X PUT \
-H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
-H "Content-Type: application/json" \
-d '{"name": "super group 3", "children": [51]}' \
https://cloud.minapp.com/oserve/v1/user-supergroup/52/
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/666/',  // 665 对应 :group_id
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${token}`,
  },
  json: {   // 指定 data 以 "Content-Type": 'application/json' 传送
    name: 'super group',
    children: [561]
  }
}

request(opt, function(err, res, body) {
  console.log(res.statusCode, body)
})
<?php
$group_id = 52; // 用户组 ID
$url = "https://cloud.minapp.com/oserve/v1/user-supergroup/{$group_id}/";
$param = array(
  'name' =>'testCreateFiles',
  'children' => [51]
);

$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, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res['response'] = curl_exec($ch); // 反馈结果
$res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
curl_close($ch);

返回示例

{
  "children": [
    {
      "id": 51,
      "name": "User Group"
    }
  ],
  "id": 52,
  "name": "super group 3"
}

删除组集

接口

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

代码示例

curl -X DELETE \
-H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
-H "Content-Type: application/json" \
https://cloud.minapp.com/oserve/v1/user-supergroup/52/
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/666/',  // 666 对应 :group_id
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${token}`,
  }
}

request(opt, function(err, res, body) {
  console.log(res.statusCode)
})
<?php
$group_id = 52; // 用户组 ID
$url = "https://cloud.minapp.com/oserve/v1/user-supergroup/{$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, 'DELETE');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res['response'] = curl_exec($ch); // 反馈结果
$res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
curl_close($ch);

状态码说明

204 删除成功

批量删除组集

接口

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

代码示例

curl -X DELETE \
-H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
-H "Content-Type: application/json" \
https://cloud.minapp.com/oserve/v1/user-supergroup/?id__in=58,56
var request = require('request');

var opt = {
  uri: 'https://cloud.minapp.com/oserve/v1/user-supergroup/?id__in=667,668',  // id__in=:667,668 对应 id__in=:group_id,group1_id
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${token}`,
  }
}

request(opt, function(err, res, body) {
  console.log(res.statusCode)
})
<?php
// 用户组 ID 集
$group_id[] = 56;
$group_id[] = 58; 
$url = "https://cloud.minapp.com/oserve/v1/user-supergroup/?id__in=".implode(',',$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, 'DELETE');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$res['response'] = curl_exec($ch); // 反馈结果
$res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
curl_close($ch);

状态码说明

204 删除成功