Created
December 4, 2017 14:20
-
-
Save sat0ken/69e875ce8b9aeb1145865e13d79421a1 to your computer and use it in GitHub Desktop.
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
import socket | |
import ssl | |
def send_message(): | |
s = socket.socket() | |
ai = socket.getaddrinfo("slack.com", 443) | |
print("Address infos:", ai) | |
addr = ai[0][-1] | |
s.connect(addr) | |
s = ssl.wrap_socket(s) | |
send_data = "token=yourtoken&channel=%23yourchannel&text=Hello!! Meassage from Micropython&username=yourname" | |
s.write(b"POST /api/chat.postMessage HTTP/1.1\r\n") | |
s.write(b"Host: slack.com\r\n") | |
s.write(b"Accept: */*\r\n") | |
s.write(b"Content-Length: %d\r\n" % len(send_data)) | |
s.write(b"Content-Type: application/x-www-form-urlencoded\r\n") | |
s.write(b"Connection: close\r\n") | |
s.write(b"\r\n") | |
s.write(send_data) | |
print(s.read(4096)) | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment