跳转至

点赞

“喜欢”可以添加到频道中的每条消息,也可以从中删除。

  • 当您调用 API 添加或移除“喜欢”时,相关的喜欢事件消息会发送给频道中的所有参与者。

添加点赞 API

为特定消息添加“点赞”。

  • 你不能对已经点赞的消息再添加一个点赞。
  • 你不能对通知消息添加点赞。

请求 URL

服务器 URL
生产环境 https://plugin-chat.withhive.com/plugin/api/like/v1/games/{gameIndex}/channels/{channelId}/messages/{messageId}
沙盒环境 https://sandbox-plugin-chat.withhive.com/plugin/api/like/v1/games/{gameIndex}/channels/{channelId}/messages/{messageId}
HTTP 方法 POST

路径参数

字段 描述 类型 必需
gameIndex Hive 游戏索引 整数
channelId 渠道 ID 字符串
messageId 消息 ID 字符串

头部参数

字段 描述 类型 必需
Authorization API 调用的身份验证令牌 (Bearer) 字符串
Content-Type 请求数据的类型 (application/json) 字符串

请求体

字段 描述 类型 必需
playerId 喜欢它的用户的玩家ID long Y

响应主体

字段 描述 类型
code 响应代码 整数
message 结果消息 字符串

请求示例

curl --location 'https://plugin-chat.withhive.com/plugin/api/like/v1/games/1/channels/open:12345/messages/0196f733-4f33-7a63-a657-5b0e5e792472' \
--header 'Content-Type: application/json' --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJIaXZlIiwiaWF0IjoxNzAyNDU4MTkzLCJqdGkiOiIxMzY2NDk4MjcxIn0.VSwvsTE-tS0sL_e9p9gNvHRkMCbsycSO4ObE4J2ysjs' \
--data '{"playerId":1}'

响应示例

{
    "code": 0,
    "message": "Success."
}

移除喜欢

从消息中移除一个点赞。

  • 你只能删除自己添加的点赞。

请求 URL

服务器 URL
直播 https://plugin-chat.withhive.com/plugin/api/like/v1/games/{gameIndex}/channels/{channelId}/messages/{messageId}/players/{playerId}
沙盒 https://sandbox-plugin-chat.withhive.com/plugin/api/like/v1/games/{gameIndex}/channels/{channelId}/messages/{messageId}/players/{playerId}
HTTP 方法 DELETE

路径参数

字段 描述 类型 必需
gameIndex Hive 游戏索引 整数
channelId 渠道 ID 字符串
messageId 消息 ID 字符串
playerId 移除点赞的用户的玩家 ID 长整型

头部参数

字段 描述 类型 必需
Authorization API 调用的认证令牌 (Bearer) 字符串

响应主体

字段 描述 类型
code 响应代码 整数
message 结果消息 字符串

请求示例

curl --location --request DELETE 'https://plugin-chat.withhive.com/plugin/api/like/v1/games/1/channels/open:12345/messages/0196f733-4f33-7a63-a657-5b0e5e792472/players/1' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJIaXZlIiwiaWF0IjoxNzAyNDU4MTkzLCJqdGkiOiIxMzY2NDk4MjcxIn0.VSwvsTE-tS0sL_e9p9gNvHRkMCbsycSO4ObE4J2ysjs'

响应示例

{
    "code": 0,
    "message": "Success."
}

响应代码

除了常见的响应代码外,以下是特定于点赞功能的响应代码。

HTTP 状态码 代码 消息 描述
400 10000 点赞未找到或已删除。 未找到点赞信息
400 10001 消息未找到或已删除。 未找到点赞信息的消息
400 10002 消息已经有点赞信息。 点赞信息已存在

API 响应包括喜欢的信息

本节解释了在channel message history API的响应中包含的类似信息。

响应体 > 数据 > 内容 > 插件数据

如果频道消息包含点赞信息,则like字段包含在频道消息历史API响应主体的**data > content > pluginData**中。

字段 描述 类型
like 喜欢的信息 对象

响应主体 > 数据 > 内容 > 插件数据 > 喜欢

字段 描述 类型
playerIds 喜欢该消息的用户的玩家ID 长整型数组

响应示例

{
  // ...omitted
        "content": [
            {
                "gameIndex": 1374,
                "from": 1,
                "messageId": "ggJ5Csh15J-mI3i5",
                "extraData": "",
                "pluginData": {
                    "like": {
                        "playerIds": [
                            1
                        ]
                    }
                },
                "to": "public:10",
                "message": "aaa",
                "langCode": "ko",
                "timestamp": "2025-07-17T00:56:17.156Z",
                "timestampMillis": 1752713777156
            }
        ]
  // ...omitted
}