-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.py
64 lines (43 loc) · 1.27 KB
/
demo.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
'''
This is a simple demo how to use this lib
'''
api_key = ''
api_secret = ''
redirect_url = 'http://localhost:4000'
try:
input = raw_input
except:
pass
def auth():
from pushcoapi.authorize import Authorize
auth = Authorize(api_key, api_secret, redirect_url)
url = auth.get_auth_url()
print('1. Go to link below')
print('2. Click Allow')
print('3. Copy the authorization code.')
print(url)
code = input("Enter the authorization code here: ").strip()
data = auth.get_access_token(code)
print(data)
access_token = data.get('access_token')
data = auth.check_access_token(access_token)
print(data)
#data = auth.delete_access_token(access_token)
#print(data)
return access_token
def subscription(access_token):
from pushcoapi.subscription import Subscription
s = Subscription(access_token)
print(s.gets())
def push():
from pushcoapi.push import Push
p = Push(api_key, api_secret)
ret = p.push_message('Hello, this is a message from demo')
print(ret)
ret = p.push_web('Hello, this is a web', 'http://guojing.me')
print(ret)
ret = p.push_map('Hello, this is a map', '39.9026266648', '116.4012871818')
print(ret)
if __name__ == '__main__':
push()