Python - send message to Slack channel
Requirement:
$ sudo apt install python-pip
$ pip install requests
$ cat sendmsg.py
--
import requests
import json
webhook = 'https://hooks.slack.com/services/T02Bxxxxx/BHL1xxxxx/RxtkmKBo0xxxxxxx'
slack_data = {
'channel': '#yourchannelname',
'text': 'Hello apa khabar'
}
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
$ sudo apt install python-pip
$ pip install requests
$ cat sendmsg.py
--
import requests
import json
webhook = 'https://hooks.slack.com/services/T02Bxxxxx/BHL1xxxxx/RxtkmKBo0xxxxxxx'
slack_data = {
'channel': '#yourchannelname',
'text': 'Hello apa khabar'
}
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
0 Comments:
Post a Comment
<< Home