Skip to content

Instantly share code, notes, and snippets.

@jamesbiederbeck
Created February 11, 2018 08:55
Show Gist options
  • Save jamesbiederbeck/0f2faa8b4744751a229a254b60b94ef5 to your computer and use it in GitHub Desktop.
Save jamesbiederbeck/0f2faa8b4744751a229a254b60b94ef5 to your computer and use it in GitHub Desktop.
A basic pushover client in python
import requests
import sys
po = "https://api.pushover.net"
token = ""
user_key = ""
messages_endpoint = "/1/messages.json"
def main(message):
r = push(message)
status = r.json()['status']
if status != 1:
print("There was a problem with the request")
print("Errors:")
print(r.json()['errors'])
return r #in case you want to call the function from another script and look closer
def push(message, user_key=user_key, token=token):
params={
"token":token,
"user":user_key,
"message":message
}
r = requests.post(po+messages_endpoint,params)
return r
if __name__ == "__main__":
args = sys.argv
if len(args) !=2:
print("Usage: python pushover.py 'message'")
main(str(args[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment