为什么Slacks交互式消息不以JSON格式发布?

Atl*_*ic0 2 slack-api slack

交互式消息应以JSON格式发送。

We'll send an HTTP POST request with information to this URL when users invoke message buttons. This URL must use the "https" protocol.
Run Code Online (Sandbox Code Playgroud)

我的请求网址如下,我缺少什么吗?

https://admin:password@domain/api/v1/slack
Run Code Online (Sandbox Code Playgroud)

Eri*_*ken 5

Slack不是直接在JSON中发布。它使用payload主体参数向您的脚本发送POST请求。此参数包含application/x-www-form-urlencoded带有JSON格式的请求的编码字符串。因此,请务必先读取JSON消息的有效负载参数。

这是一个有关如何读取payloadPHP参数的示例:

$payload_json = filter_input(INPUT_POST, 'payload', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES );
$payload = json_decode ($payload_json, true);
Run Code Online (Sandbox Code Playgroud)

有关示例,请参见此处获取官方文档。