Created
January 12, 2018 22:21
-
-
Save SkaTeMasTer/cce382e4b61162148d6630ed546781ae to your computer and use it in GitHub Desktop.
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
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