Python 对松弛块消息进行编码
这项工作:Python 对松弛块消息进行编码,python,slack,Python,Slack,这项工作: client.chat_postMessage( channel=channel, thread_ts = thread_ts, blocks= [ { "type": "section", "text": { "type": "mrkdwn",
client.chat_postMessage(
channel=channel,
thread_ts = thread_ts,
blocks=
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Danny Torrence left the following review for your property:"
}
},
[ ... and so on... more sections ...]
)
但这不起作用:
client.chat_postMessage(
channel=channel,
thread_ts = thread_ts,
blocks=blockmsg
)
其中blockmsg是我在程序前面定义的多行文字。Slack只是不发布“blockmsg”,它是静默的,即没有错误消息
这里有什么“问题”吗?您能重构代码,将多行文字转换成JSON吗?Slack文档提到,
blocks
是“一个基于JSON的结构化块数组,以URL编码的字符串表示。”您的文本是JSON字符串还是Python字典?它是JSON字符串。我弄明白了,我打错了。即使是一个打字错误也是致命的