【发布时间】:2018-05-30 09:53:06
【问题描述】:
我正在尝试将附件发送到 Slack 网络挂钩。
我已遵循 API 文档,可以发送简单的消息。当我尝试发送附件时收到 500 错误,我认为我的有效负载存在问题,但我终生无法解决。
如何让附件发布成功?
import slackweb
slack = slackweb.Slack(url='WEB HOOK URL HERE')
slack.notify(text="Maguro is a sushi")
attachments = []
attachment = {
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"color": "#36a64f",
"pretext": "Optional text that appears above the attachment block",
"author_name": "Bobby Tables",
"author_link": "http://flickr.com/bobby/",
"author_icon": "http://flickr.com/icons/bobby.jpg",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/",
"text": "Optional text that appears within the attachment",
"fields": [
{
"title": "Priority",
"value": "High",
"short": False
}
],
"image_url": "http://my-website.com/path/to/image.jpg",
"thumb_url": "http://example.com/path/to/thumb.png",
"footer": "Slack API",
"footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png",
"ts": 123456789
}
]
}
attachments.append(attachment)
slack.notify(attachments=attachments)
【问题讨论】:
标签: python python-3.x slack slack-api