def send_to_slack(text, username, icon_emoji, webhook):
values = {'payload': '{"username": "' + username + '", '
'"icon_emoji": "' + icon_emoji + '", '
'"text": "' + text + '"}'
}
str_values = {}
for k, v in values.items():
str_values[k] = unicode(v).encode('utf-8')
data = urllib.urlencode(str_values)
h = httplib.HTTPSConnection('hooks.slack.com')
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
h.request('POST', webhook, data, headers)
r = h.getresponse()
# ack = r.read()
# print data
# print ack
评论列表
文章目录