交互式消息应以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)
Slack不是直接在JSON中发布。它使用payload
主体参数向您的脚本发送POST请求。此参数包含application/x-www-form-urlencoded
带有JSON格式的请求的编码字符串。因此,请务必先读取JSON消息的有效负载参数。
这是一个有关如何读取payload
PHP参数的示例:
$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)
有关示例,请参见此处获取官方文档。