Created
September 29, 2016 21:48
-
-
Save jeffeb3/d6f7b72e3b7da8d10f18254643282533 to your computer and use it in GitHub Desktop.
Post to slack from a MicroPython (esp 8266, version 1.8.4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def slack_it(msg): | |
''' Send a message to a predefined slack channel.''' | |
import urequests | |
# Get an "incoming-webhook" URL from your slack account. @see https://api.slack.com/incoming-webhooks | |
URL='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' | |
headers = {'content-type': 'application/json'} | |
data = '{"text":"%s"}' % msg | |
resp = urequests.post(URL, data=data, headers=headers) | |
return resp | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment