GET https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type={target_type}&target_id={target_id}
支持分页参数和排序:(通用说明?)
支持时间范围过滤
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
target_type | 是 | 无 | 评论对象类型,支持:answer,doc。 answer 表示乐问回答的评论 doc 表示文档的评论 |
target_id | 是 | 无 | 评论对象的id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('comments', [
'target_type' => 'answer',
'target_id' => 'answer_uuid'
]);
document
{
"data": [
{
"type": "comment",
"id": "808abd4e484411eca94d7e20e322797f",
"attributes": {
"content": "评论",
"created_at": "2021-11-18 15:52:39"
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "silee"
}
}
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=doc&target_id=7c6cca86484411ec922f960346af4b7a&page=1",
"last": "https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=doc&target_id=7c6cca86484411ec922f960346af4b7a&page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/comments",
"per_page": 20,
"to": 1,
"total": 1
},
"included": [
{
"type": "staff",
"id": "silee",
"attributes": {
"name": "李四",
"english_name": null,
"organization": "测试部"
}
}
]
}
document
{
"data": [{
"type": "comment",
"id": "311e2790477311ecb7822ac6d5b752b7",
"attributes": {
"content": "二级评论",
"created_at": "2021-11-17 14:54:21"
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "threezhang"
}
}
}
},
{
"type": "comment",
"id": "177ed6ae477311ecb0a742ed4b6c2348",
"attributes": {
"content": "一级评论",
"created_at": "2021-11-17 14:53:38"
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "silee"
}
}
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=answer&target_id=5261ddb846bd11ecb0b3b22bd4419469&page=1",
"last": "https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=answer&target_id=5261ddb846bd11ecb0b3b22bd4419469&page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/comments",
"per_page": 20,
"to": 2,
"total": 2
},
"included": [{
"type": "staff",
"id": "threezhang",
"attributes": {
"name": "张三",
"english_name": null,
"organization": "测试部"
}
},
{
"type": "staff",
"id": "silee",
"attributes": {
"name": "李四",
"english_name": null,
"organization": "测试部"
}
}
]
}
POST https://lxapi.lexiangla.com/cgi-bin/v1/comments
document
{
"data": {
"type": "comment",
"attributes": {
"content": "用API对文档评论"
},
"relationships": {
"target": {
"data": {
"type": "doc",
"id": "cae375aae25a11e88d2c10e7c61c70fc"
}
}
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
content | 是 | 无 | 评论内容 |
target.type | 是 | 无 | 评论对象类型,支持:doc、answer、comment doc 表示对文档评论,answer 表示对乐问回答评论,comment 表示回复评论、回复评论的回复,仅支持文档和乐问 |
target.id | 是 | 无 | 评论对象的id |
$attributes = [
'content' => '用API对文档评论',
'target_type' => 'doc',
'target_id' => 'cae375aae25a11e88d2c10e7c61c70fc',
// 回复评论,
// 'target_type' => 'comment',
// 'target_id' => '8f2f0f5ae66b11e898c010e7c61c70fc',
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postComment(StaffID, $attributes);
document
{
"data": {
"type": "comment",
"id": "8f2f0f5ae66b11e898c010e7c61c70fc",
"attributes": {
"content": "用API对文档评论",
"updated_at": "2018-11-12 19:10:27",
"created_at": "2018-11-12 19:10:27"
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "ThreeZhang"
}
}
}
},
"included": [
{
"type": "staff",
"id": "ThreeZhang",
"attributes": {
"name": "张三",
"english_name": "ThreeZhang"
}
}
]
}
DELETE https://lxapi.lexiangla.com/cgi-bin/v1/comments/{comment_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
comment_id | 是 | 无 | 资源对象类型为 comment 的资源对象id,即评论id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->forStaff(StaffID)->delete('comments/comment_id');
document