Created
July 28, 2011 21:49
-
-
Save marccampbell/1112665 to your computer and use it in GitHub Desktop.
Pager.io API Example: Create Alert
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 urllib, urllib2, base64 | |
team_name = 'My Pager.io Team Name' | |
api_key = 'My Pager.io API Key' | |
alert_subject = 'Test Alert' | |
alert_message = 'This is where you would put a longer alert message' | |
data = {'subject': alert_subject, 'message': alert_message} | |
base64string = base64.encodestring('%s:%s' % (team_name, api_key)).replace('\n', '') | |
request.add_header("Authorization", "Basic %s" % base64string) | |
opener = urllib2.build_opener(urllib2.HTTPHandler) | |
request = urllib2.Request('https://pager.io/api/v1/alert', data=urllib.urlencode(data)) | |
request.add_header('Content-Type', 'application/x-www-formurlencoded') | |
request.get_method = lambda: 'POST' | |
url = opener.open(request) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment