Skip to content

Instantly share code, notes, and snippets.

@bjarneo
Last active August 29, 2015 14:15
Show Gist options
  • Save bjarneo/1fc3fc884e8f4556d8bf to your computer and use it in GitHub Desktop.
Save bjarneo/1fc3fc884e8f4556d8bf to your computer and use it in GitHub Desktop.
Pushover - send basic msg
#!/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