#!/usr/bin/env python
# encoding: utf-8
import json
import requests
def main():
'''main
'''
# HTTP POST Request
s_url = 'https://hooks.slack.com/services/T00000000/B00000000/000000000000000000000000'
dict_headers = {'Content-type': 'application/json'}
dict_payload = {
"channel": "bigtalkinfo",
"attachments": [
{
"fallback": "Plain-text summary of the attachment.",
"color": "#2eb886",
"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": "[EC2] 有一台 p2.16xlarge 啟動($14.4/hr)! 快去瞧瞧! Instance ID: i-0f79c4167c706776c ",
"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
}
]
}
json_payload = json.dumps(dict_payload)
rtn = requests.post(s_url, data=json_payload, headers=dict_headers)
print(rtn.text)
return None
if __name__ == '__main__':
main()
[Up]常用資訊
[重點文章] 重點文章 [重點文章] 重點文章
2020年3月28日 星期六
[PYTHON] 使用 python 發送訊息
[PYTHON] 使用 python 發送訊息
使用 python 發送 slack 訊息
訂閱:
張貼留言 (Atom)
-
[SHELL] grep 指令使用 or 及 and 查兩個條件以上
-
[Debian] Zabbix 5.0 安裝 中文化
沒有留言:
張貼留言