点赞

给文档,回答点赞操作

创建点赞

接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/v1/likes

请求document

{
    "data": {
        "type": "like", 
        "relationships": {
            "target": {
                "data": {
                    "type": "doc", 
                    "id": "cae375aae25a11e88d2c10e7c61c70fc"
                }
            }
        }
    }
}

参数说明:

参数 是否必须 默认值 说明
target.type 点赞对象类型,目前仅支持 doc。表示对文档点赞
target.id 点赞对象的ID

SDK封装方法使用示例:

$attributes = [
	'target_type' => 'doc',
	'target_id'   => 'cae375aae25a11e88d2c10e7c61c70fc',
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postLike(StaffID, $attributs);

响应document

200 OK 状态码
{
    "data": {
        "type": "like",
        "id": "9d125daef1f411e8923801cf1916efb0",
        "attributes": {
            "created_at": "2018-11-17 11:29:14"
        },
        "relationships": {
            "owner": {
                "data": {
                    "type": "staff",
                    "id": "StaffID"
                }
            },
            "target": {
                "data": {
                    "type": "document",
                    "id": "2e4b7a86f1ea11e88555dd35d3856b57"
                }
            }
        }
    },
    "included": [
        {
            "type": "staff",
            "id": "StaffID",
            "attributes": {
                "name": "张三",
                "english_name": "ZhangThree"
            }
        },
        {
            "type": "document",
            "id": "2e4b7a86f1ea11e88555dd35d3856b57",
            "attributes": {
                "summary": "here is the titlehello world!",
                "is_markdown": "0",
                "content": "hello world",
                "source": "original",
                "reship_url": null,
                "read_count": "0",
                "comment_count": "0",
                "like_count": "1",
                "favorite_count": "0",
                "md_content": ""
            }
        }
    ]
}

取消点赞

接口调用说明:

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/likes/{LikeID}

参数说明:

参数 是否必须 默认值 说明
LikeID 资源对象类型为 like 的资源对象ID,即点赞ID

SDK封装方法使用示例:

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

响应document

204 No Content 状态码