创建新组的 API 请求
请求URL
https://yourwebsiteaddress/api_request/
请求包体
| 字段 | 描述/值 | 必填/可选 |
|---|---|---|
| api_secret_key | 您的 MeiChat API 密钥。对于 API 秘密密钥,点击菜单>选择设置 > 选择“通用设置” > 查找 API 密钥 | 必填 |
| add | groups | 必填 |
| group_name | 新组建的乐队名称。 | 必填 |
| description | 组别简介 | 可选 |
| group_category_id | 组类识别码 | 可选 |
| slug | 这是对该群组来说对网址友好的蛞蝓。 | 可选 |
| secret_group | 私密群组,对非成员完全隐藏。[是的|不] | 可选 |
| unleavable | 用户不得离开本群组 [是的|不允许] | 可选 |
| pin_group | 当您钉选一个组时,它会显示在组列表顶部。[是的|不] | 可选 |
| password_protect | 群组可以设置密码保护,需要密码才能查看/加入群组 [是的|不] | 可选 |
| password | 群组密码 | |
| group_icon_url | 组图标图片的网址 | 可选 |
| custom_field_[id] |
将[id]替换为自定义字段ID。
自定义字段ID:点击菜单>选择模块>选择自定义字段>点击您偏好添加的自定义字段>选择编辑>查找“标识符”。 |
可选 |
响应包体
| 键 | 描述/值 |
|---|---|
| success | 成功时会回应此理,失败时则为false。 |
| error_message | 返回相关的错误信息 |
| error_key | 该方法返回与错误相关的错误键 |
PHP 代码示例
<?php
$meichat_web_address = 'https://yourwebsiteaddress';
$post_fields=[
'api_secret_key' => 'Your_MeiChat_API_Secret_Key',
'add' => 'groups',
'group_name' => 'Group Name',
'description' => 'Group Description',
'slug' => 'group_slug',
'group_category_id'=>'1',
'secret_group' => 'no',
'unleavable' => 'no',
'pin_group' => 'no',
'password_protect' => 'no',
'password' => 'password',
'group_icon_url' => 'https://group_icon_image_url',
'custom_field_10' => 'Custom Field Value',
];
$api_request_url = rtrim($meichat_web_address, '/').'/'.'api_request/';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $api_request_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $post_fields,
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0'
));
$response = curl_exec($curl);
curl_close($curl);
if (!empty($response)) {
$response = json_decode($response);
if (!empty($response)) {
if ($response->success) {
echo "Group Created Successfully.";
} else {
echo $response->error_message;
}
}
}
?>