Skip to content

Instantly share code, notes, and snippets.

@ejm
Created November 17, 2015 01:29
Show Gist options
  • Save ejm/924aac6d81953a3ad492 to your computer and use it in GitHub Desktop.
Save ejm/924aac6d81953a3ad492 to your computer and use it in GitHub Desktop.
Push a message to a Pushbullet account
#!/usr/bin/python
# pushbullet_msg.py - Push a message to a Pushbullet account
import argparse, requests, sys
MESSAGE_URL = "https://api.pushbullet.com/v2/pushes"
def push_msg(title, body, key):
push_data = {"type":"note", "title":title, "body":body}
r = requests.post(MESSAGE_URL, auth=requests.auth.HTTPBasicAuth(key, ""), data=push_data)
return r.text
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Sends push notifications")
parser.add_argument("--title", default="A message from Python")
parser.add_argument("--body", default=sys.stdin)
parser.add_argument("--key", required=True)
args = parser.parse_args()
push_msg(args.title, args.body, args.key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment