GET https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=TARGET_TYPE&target_id=TARGET_ID
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
target.type | 是 | 无 | 评论对象类型,支持:answer。 answer 表示乐问回答的评论 |
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": "6ae89410193c11e8aba12063590908c3",
"attributes": {
"content": "评论内容",
"created_at": "2018-02-24 16:26:31"
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "STAFF1"
}
}
}
},
{
"type": "comment",
"id": "024c181c193911e8b24b19f87eaee149",
"attributes": {
"content": "回复 @STAFF1 :回复评论",
"created_at": "2018-02-24 16:02:07"
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "STAFF1"
}
}
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=answer&target_id=d5f04360193811e8b2f0b926dc5ffc99&page=1",
"last": "https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=answer&target_id=d5f04360193811e8b2f0b926dc5ffc99&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": "STAFF1",
"attributes": {
"name": "张三",
"english_name": "peter"
}
}
]
}
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, $attributs);
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/{CommentID}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
CommentID | 是 | 无 | 资源对象类型为 comment 的资源对象ID,即评论ID |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->forStaff(StaffID)->delete('comments/CommentID');
document