人生若只如初见

WXY

Halo插件plugin-webhook使用文档

2024-04-24

简介

plugin-webhook 是一个为 Halo (强大易用的开源建站工具)设计的Webhook插件。

Webhook 是一种通过 HTTP 协议实现的回调机制,允许用户在特定事件发生时(如文章发布、新评论、回复评论等事件)将数据推送到指定的 Webhook URL。这种机制使得用户可以实时地将事件通知发送到外部系统,从而实现与其他服务的集成。

2024-04-24-zrrkqrzy.png

安装

如何安装和配置plugin-webhook插件。

1. 下载,目前提供以下下载方式:

GitHub Releases:访问 [Releases] 下载 Assets 中的 JAR 文件。

安装,插件安装和更新方式可参考:https://docs.halo.run/user-guide/plugins

安装完成之后,记得启用插件并完成相关配置。

2. Halo应用商店安装

https://www.halo.run/store/apps/app-sCQyp

事件具体说明

TEST_WEBHOOK("测试webhook")

测试(点击插件配置中的测试按钮触发)

发送数据

{
  "eventType": "TEST_WEBHOOK",
  "eventTypeName": "测试webhook",
  "hookTime": "2024-04-24 16:16:51",
  "data": "Test webhook success"
}

NEW_POST("发布文章")

发布新的文章(点击文章发布按钮时触发)

发送数据

{
  "eventType": "NEW_POST",
  "eventTypeName": "发布文章",
  "hookTime": "2024-04-24 16:39:26",
  "data": {
    "title": "测试webhook文章",
    "slug": "1713947947650",
    "permalink": "/archives/1713947947650",
    "visible": "PUBLIC",
    "owner": "wxy",
    "createTime": "2024-04-24 16:39:23",
    "publishTime": "2024-04-24 16:39:26",
    "isPermanent": null
  }
}

DELETE_POST("删除文章")

点击文章删除按钮 或 回收站中的永久删除按钮时触发

删除文章 发送数据

{
  "eventType": "DELETE_POST",
  "eventTypeName": "删除文章",
  "hookTime": "2024-04-24 16:42:12",
  "data": {
    "title": "测试webhook文章",
    "slug": "1713947947650",
    "permalink": "/archives/1713947947650",
    "visible": "PUBLIC",
    "owner": "wxy",
    "createTime": "2024-04-24 16:39:23",
    "publishTime": "2024-04-24 16:39:23",
    "isPermanent": false
  }
}

永久删除 发送数据

{
  "eventType": "DELETE_POST",
  "eventTypeName": "删除文章",
  "hookTime": "2024-04-24 16:43:05",
  "data": {
    "title": "测试webhook文章",
    "slug": "1713947947650",
    "permalink": "/archives/1713947947650",
    "visible": "PUBLIC",
    "owner": "wxy",
    "createTime": "2024-04-24 16:39:23",
    "publishTime": "2024-04-24 16:39:23",
    "isPermanent": true
  }
}

NEW_COMMENT("发表评论")

在文章或页面发表新评论时触发

发送数据

{
  "eventType": "NEW_COMMENT",
  "eventTypeName": "发表评论",
  "hookTime": "2024-04-24 16:44:40",
  "data": {
    "owner": {
      "kind": "User",
      "name": "wxy",
      "displayName": "Administrator",
      "annotations": null
    },
    "content": "我在关于页面发布了评论",
    "createTime": "2024-04-24 16:44:40",
    "approved": true,
    "refKind": "SinglePage",
    "postData": null,
    "singlePageData": {
      "title": "关于",
      "slug": "about",
      "visible": "PUBLIC",
      "owner": "wxy",
      "createTime": "2024-04-24 09:32:20",
      "publishTime": "2024-04-24 09:32:20"
    },
    "replyComment": null
  }
}

DELETE_COMMENT("删除评论")

前台界面好像不支持删除,在console删除评论时触发(删除回复不触发该事件)

发送数据

{
  "eventType": "DELETE_COMMENT",
  "eventTypeName": "删除评论",
  "hookTime": "2024-04-24 16:47:46",
  "data": {
    "owner": {
      "kind": "User",
      "name": "wxy",
      "displayName": "Administrator",
      "annotations": null
    },
    "content": "我在关于页面发布了评论",
    "createTime": "2024-04-24 16:44:40",
    "approved": true,
    "refKind": "SinglePage",
    "postData": null,
    "singlePageData": {
      "title": "关于",
      "slug": "about",
      "visible": "PUBLIC",
      "owner": "wxy",
      "createTime": "2024-04-24 09:32:20",
      "publishTime": "2024-04-24 09:32:20"
    },
    "replyComment": null
  }
}

REPLY_COMMENT("回复评论")

在文章或页面 回复评论时触发

发送数据

{
  "eventType": "REPLY_COMMENT",
  "eventTypeName": "回复评论",
  "hookTime": "2024-04-24 16:49:37",
  "data": {
    "owner": {
      "kind": "User",
      "name": "wxy",
      "displayName": "Administrator",
      "annotations": null
    },
    "content": "我是关于页面的第一条评论",
    "createTime": "2024-04-24 16:49:30",
    "approved": true,
    "refKind": "SinglePage",
    "postData": null,
    "singlePageData": {
      "title": "关于",
      "slug": "about",
      "visible": "PUBLIC",
      "owner": "wxy",
      "createTime": "2024-04-24 09:32:20",
      "publishTime": "2024-04-24 09:32:20"
    },
    "replyComment": {
      "owner": {
        "kind": "User",
        "name": "wxy",
        "displayName": "Administrator",
        "annotations": null
      },
      "content": "我回复你一下试试",
      "createTime": "2024-04-24 16:49:37",
      "approved": true,
      "refKind": null,
      "postData": null,
      "singlePageData": null,
      "replyComment": null
    }
  }
}

DELETE_REPLY_COMMENT("删除回复")

在console中删除评论回复时触发

发送数据

{
  "eventType": "DELETE_REPLY_COMMENT",
  "eventTypeName": "删除回复",
  "hookTime": "2024-04-24 16:51:04",
  "data": {
    "owner": {
      "kind": "User",
      "name": "wxy",
      "displayName": "Administrator",
      "annotations": null
    },
    "content": "我是关于页面的第一条评论",
    "createTime": "2024-04-24 16:49:30",
    "approved": true,
    "refKind": "SinglePage",
    "postData": null,
    "singlePageData": {
      "title": "关于",
      "slug": "about",
      "visible": "PUBLIC",
      "owner": "wxy",
      "createTime": "2024-04-24 09:32:20",
      "publishTime": "2024-04-24 09:32:20"
    },
    "replyComment": {
      "owner": {
        "kind": "User",
        "name": "wxy",
        "displayName": "Administrator",
        "annotations": null
      },
      "content": "我回复你一下试试",
      "createTime": "2024-04-24 16:49:37",
      "approved": true,
      "refKind": null,
      "postData": null,
      "singlePageData": null,
      "replyComment": null
    }
  }
}

如使用中遇到任何问题或有好的建议都可以在该文章下评论