Last active
August 29, 2015 14:15
-
-
Save bjarneo/1fc3fc884e8f4556d8bf to your computer and use it in GitHub Desktop.
Pushover - send basic msg
This file contains hidden or 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 urllib | |
import urllib2 | |
import json | |
config = { | |
'api': 'https://api.pushover.net/1/messages.json', | |
'user': 'user_key', | |
'token': 'your_token' | |
} | |
def sendMessage(title='', msg=''): | |
data = urllib.urlencode({ | |
'user': config['user'], | |
'token': config['token'], | |
'title': title, | |
'message': msg | |
}) | |
try: | |
req = urllib2.Request(config['api'], data) | |
response = urllib2.urlopen(req) | |
except urllib2.HTTPError: | |
print 'Failed much' | |
return False | |
res = json.load(response) | |
if res['status'] == 1: | |
print 'Pushover Success' | |
else: | |
print 'Pushover Fail' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment