Skip to content

Instantly share code, notes, and snippets.

@LewisLebentz
Last active January 29, 2017 16:57
Show Gist options
  • Save LewisLebentz/c6cb00b76db38b5de9e7a84b650e23e1 to your computer and use it in GitHub Desktop.
Save LewisLebentz/c6cb00b76db38b5de9e7a84b650e23e1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
from urllib2 import Request, urlopen
def post(event, context):
V2TOKEN = 'enter_token_here'
ROOMID = enter_room_id_here
# API V2, send message to room:
url = 'https://api.hipchat.com/v2/room/%d/notification' % ROOMID
message = "Write your message here"
headers = {
"content-type": "application/json",
"authorization": "Bearer %s" % V2TOKEN}
datastr = json.dumps({
'message': message,
'color': 'purple',
'message_format': 'html',
'notify': False,
'from': 'Lambda'})
request = Request(url, headers=headers, data=datastr)
uo = urlopen(request)
rawresponse = ''.join(uo)
uo.close()
assert uo.code == 204
return "Success"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment