评论

创建评论

接口调用说明:

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、comment。
doc 表示对文档评论,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 状态码