要求(ubuntu):
$ sudo apt安装python-pip
$ pip安装请求
$猫sendmsg.py
import requests
import json
webhook = 'https://hooks.slack.com/services/T02Bxxxxx/BHL1xxxxx/RxtkmKBo0xxxxxxx'
slack_data = {
'channel': '#yourchannelname',
'text': 'Hello world'
}
response = requests.post(webhook, data=json.dumps(slack_data), headers={'Content-Type':'application/json'})
print('Response: ' + str(response.text))
print('Status code: ' + str(response.status_code))
$ python sendmsg.py
回应:好的
状态码:200