Last active
January 29, 2017 16:57
-
-
Save LewisLebentz/c6cb00b76db38b5de9e7a84b650e23e1 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
#!/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