forked from danielfennelly/SAAT-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush.py
More file actions
26 lines (20 loc) · 793 Bytes
/
push.py
File metadata and controls
26 lines (20 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
def push_link(title, body, url, access_token):
data = {'type': 'link', 'title': title, 'body': body, 'url': url}
headers = {'Access-Token': access_token}
r = requests.post('https://api.pushbullet.com/v2/pushes', data=data,
headers=headers)
return r
def get_access_token(filename):
with open(filename) as f:
token = f.readline().strip()
if token:
return token
return None
if __name__ == "__main__":
access_token = get_access_token('access_token')
url = "https://raw.githubusercontent.com/diracdeltas/beatsbywatson/master/src/watson.jpg"
if access_token:
print(push_link('Change Your Mind', 'Fill out Mood Survey', url, access_token))
else:
print('No access token!')