评论

获取评论列表

接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/comments?target_type=TARGET_TYPE&target_id=TARGET_ID

参数说明:

参数 是否必须 默认值 说明
target.type 评论对象类型,支持:answer。
answer 表示乐问回答的评论
target.id 评论对象的ID

SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('comments', [
    'target_type' => 'answer',
    'target_id' => 'answer_uuid'
]);

响应document

200 OK 状态码
{
    "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

SDK封装方法使用示例:

$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

201 Created 状态码
{
    "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

SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->forStaff(StaffID)->delete('comments/CommentID');

响应document

204 No Content 状态码