# 点赞

给文档,回答点赞操作

# 获取点赞列表

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/likes?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('likes', [
    'target_type' => 'answer',
    'target_id' => 'answer_uuid'
]);

# 响应document

# 200 OK 状态码
{
    "data": [
        {
            "type": "like",
            "id": "6ae89420193c11e8aba12063590908c3",
            "attributes": {
                "created_at": "2018-02-24 16:26:31"
            },
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff",
                        "id": "STAFF1"
                    }
                }
            }
        },
        {
            "type": "like",
            "id": "024c181c193901e8b24b19f87eaee149",
            "attributes": {
                "created_at": "2018-02-24 16:02:07"
            },
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff",
                        "id": "STAFF1"
                    }
                }
            }
        }
    ],
    "links": {
        "first": "https://lxapi.lexiangla.com/cgi-bin/v1/likes?target_type=answer&target_id=d5f04360193811e8b2f0b926dc5ffc99&page=1",
        "last": "https://lxapi.lexiangla.com/cgi-bin/v1/likes?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/likes",
        "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/likes

# 请求document

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

# 参数说明:

参数 是否必须 默认值 说明
target.type 点赞对象类型,目前仅支持 doc、answer。表示对文档和回答点赞,参数为answer时不能为自己回答点赞
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": "ThreeZhang"
                }
            },
            "target": {
                "data": {
                    "type": "document",
                    "id": "2e4b7a86f1ea11e88555dd35d3856b57"
                }
            }
        }
    },
    "included": [
        {
            "type": "staff",
            "id": "ThreeZhang",
            "attributes": {
                "name": "张三",
                "english_name": "ThreeZhang"
            }
        },
        {
            "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 状态码