推送消息
如 简介 中所述,您需要一个应用程序来向 gotify/server推送消息。只有创建该应用程序的用户才能查看其消息。 可以通过以下方式添加应用程序:
- WebUI:登录后点击右上角的 “应用” 标签页,添加应用
- REST-API: curl -u admin:admin https://yourdomain.com/application -F “name=test” -F “description=tutorial” 参见 API 文档
要作为应用程序进行身份验证,您需要应用程序令牌。该令牌会在 REST 请求中返回,并可在 Web 界面中查看。
现在,你可以轻松使用 curl、HTTPie 或任何其他已安装的 http 客户端来推送消息。
$ curl "https://push.example.de/message?token=<apptoken>" -F "title=my title" -F "message=my message" -F "priority=5"
$ http -f POST "https://push.example.de/message?token=<apptoken>" title="my title" message="my message" priority="5"在微软的 PowerShell 中,您也可以选择使用内置的 Invoke-RestMethod或 Invoke-WebRequest 命令。
PS> Invoke-RestMethod -Uri "https://push.example.de/message?token=<apptoken>" -Method POST -Body @{title="my title"; message="my message"; priority=5} # return is automatically parsed into a PowerShell object
PS> Invoke-WebRequest -Uri "https://push.example.de/message?token=<apptoken>" -Method POST -Body @{title="my title"; message="my message"; priority=5} # return is as raw response消息 API 包含一个 extras 属性,用于携带与消息相关的额外信息,并描述客户端对此消息的行为方式。 更多详情请参阅 消息附加信息 。
自 gotify/server v1.2.0 版本起,仅 message 参数为必填项。
你也可以使用 gotify/cli 来推送消息。 该 CLI 会将 URL 和令牌存储在配置文件中。
$ gotify push -t "my title" -p 10 "my message"
$ echo my message | gotify push作者:Jeebiz 创建时间:2025-12-04 10:50
最后编辑:Jeebiz 更新时间:2025-12-04 11:29
最后编辑:Jeebiz 更新时间:2025-12-04 11:29