POST https://lxapi.lexiangla.com/cgi-bin/v1/categories
document
{
"data": {
"type": "category",
"attributes": {
"name": "API新建分类",
"target_type": "doc",
"weight": 10
},
"relationships": {
"parent": {
"data": {
"type": "category",
"id": "3dc335a852dc11e6b49a0800278acc25"
}
}
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
name | 是 | 无 | 分类名称 |
target_type | 是 | 无 | 分类所属模块,支持:doc、thread、team、class、course。 doc 表示文档,thread 表示论坛,team 表示K吧 |
weight | 否 | 0 | 用于分类排序,越小越优先展示 |
parent | 否 | 无 | 父分类 |
$attributs = [
'name' => 'API新建分类',
'target_type' => 'doc'
];
$options = [
'parent_id' => '3dc335a852dc11e6b49a0800278acc25',
'weight' => 10
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postCategory(StaffID, $attributs, $options);
document
{
"data": {
"type": "directory",
"id": "9a76e154cd3811e8b2b8cfb4fc928df1",
"attributes": {
"name": "开放接口目录"
}
}
}
PATCH https://lxapi.lexiangla.com/cgi-bin/v1/categories/{categoryId}
document
{
"data": {
"type": "category",
"attributes": {
"name": "API新建分类_putw"
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
categoryId | 是 | 无 | 分类ID |
category.name | 是 | 无 | 分类名称 |
$Lxapi = new \Lexiangla\Openapi\Api($app_key, $app_secret);
$attributes = [
'name' => 'API新建分类_putw',
];
$response = $Lxapi->patchCategory('StaffID','ef380b7ca67911e89a9f10e7c61c70fc', $attributes);
document
{
"data": {
"type": "category",
"id": "b485e9d0f00711e9a9795254009b5a66",
"attributes": {
"name": "API更新分类"
}
}
}
{
"errors": {
"detail": "该分类已存在"
}
}
DELETE https://lxapi.lexiangla.com/cgi-bin/v1/categories/{categoryId}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
categoryId | 是 | 无 | 分类ID |
$Lxapi = new \Lexiangla\Openapi\Api($app_key, $app_secret);
$response = $Lxapi->deleteCategory('StaffID','ef380b7ca67911e89a9f10e7c61c70fc');
document
[]
{
"errors": {
"detail": "不存在ID为`fab2ec5eefef11e99cb65254009b5a66`的category资源"
}
}
可以获取应用的分类属性,用于设置实体的 category_id 属性
GET https://lxapi.lexiangla.com/cgi-bin/v1/categories
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
target_type | 是 | 无 | 需要获取分类列表的应用类型,支持:doc、thread、class、course、team。 doc 表示文档,thread 表示论坛,class表示课程,course表示课堂素材,team 表示K吧 |
parent_id | 否 | 无 | 父分类ID,为空时默认拉取第一级分类,若要拉取次级分类需要添加此参数 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('categories', [
'target_type' => 'doc',
// 'parent_id' => '3dc35dda52dc11e6ae140800278acc25',
]);
document
{
"data":[
{
"type":"category",
"id":"3dc335a852dc11e6b49a0800278acc25",
"attributes":{
"name":"技术运维"
},
"meta":{
"children_count":"0"
}
},
{
"type":"category",
"id":"3dc35dda52dc11e6ae140800278acc25",
"attributes":{
"name":"产品市场"
},
"meta":{
"children_count":"2"
}
},
{
"type":"category",
"id":"3dc38ce252dc11e6a16f0800278acc25",
"attributes":{
"name":"设计用研"
},
"meta":{
"children_count":"0"
}
},
{
"type":"category",
"id":"3dc3e2dc52dc11e695060800278acc25",
"attributes":{
"name":"质量管理"
},
"meta":{
"children_count":"0"
}
},
{
"type":"category",
"id":"3dc3f7e052dc11e690ef0800278acc25",
"attributes":{
"name":"企管文化"
},
"meta":{
"children_count":"0"
}
},
{
"type":"category",
"id":"3dc4337252dc11e693940800278acc25",
"attributes":{
"name":"其他"
},
"meta":{
"children_count":"0"
}
}
]
}
GET https://lxapi.lexiangla.com/cgi-bin/v1/categories/{id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
id | 是 | 无 | 分类ID |
document
{
"data": {
"type": "category",
"id": "926f1deefbd711eaa44f22f21195fed5",
"attributes": {
"name": "入职须知"
},
"relationships": {
"parent": {
"data": {
"type": "category",
"id": "926ed9a6fbd711ea92e222f21195fed5"
}
}
}
},
"included": [
{
"type": "category",
"id": "926ed9a6fbd711ea92e222f21195fed5",
"attributes": {
"name": "开课分类"
}
}
]
}
{
"errors": {
"detail": "不存在ID为`fab2ec5eefef11e99cb65254009b5a66`的category资源"
}
}