Skip to content

Instantly share code, notes, and snippets.

@TheSkorm
Created October 26, 2015 02:43
Show Gist options
  • Select an option

  • Save TheSkorm/ca0382f3df083cc3480c to your computer and use it in GitHub Desktop.

Select an option

Save TheSkorm/ca0382f3df083cc3480c to your computer and use it in GitHub Desktop.
#https://www.python.org/ftp/python/3.3.0/python-3.3.0.msi
#http://pycurl.sourceforge.net/download/pycurl-7.19.5.1.win32-py3.3.exe
import pycurl
from io import BytesIO
import json
buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'https://hooks.slack.com/services/XXXXXXXX')
post_data = {"text": "This is a line of text in a channel.\nAnd this is another line of text."}
postfields = json.dumps(post_data)
c.setopt(pycurl.HTTPHEADER, ['Accept: application/json'])
c.setopt(pycurl.POST, 1)
c.setopt(c.POSTFIELDS, postfields)
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment