Skip to content

Instantly share code, notes, and snippets.

@SkaTeMasTer
Created January 12, 2018 22:21
Show Gist options
  • Save SkaTeMasTer/cce382e4b61162148d6630ed546781ae to your computer and use it in GitHub Desktop.
Save SkaTeMasTer/cce382e4b61162148d6630ed546781ae to your computer and use it in GitHub Desktop.
import requests
import json
def send_notification_via_pushbullet(title, body):
""" Sending notification via pushbullet.
Args:
title (str) : title of text.
body (str) : Body of text.
"""
data_send = {"type": "note", "title": title, "body": body}
ACCESS_TOKEN = 'your_access_token'
resp = requests.post('https://api.pushbullet.com/v2/pushes', data=json.dumps(data_send),
headers={'Authorization': 'Bearer ' + ACCESS_TOKEN, 'Content-Type': 'application/json'})
if resp.status_code != 200:
raise Exception('Something wrong')
else:
print 'complete sending'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment