-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.py
More file actions
33 lines (25 loc) · 990 Bytes
/
send.py
File metadata and controls
33 lines (25 loc) · 990 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
27
28
29
30
31
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub
##pubnub = PubNub(
## publish_key = "pub-c-5547bc05-fdd3-489e-b4bc-930fb835441d",
## subscribe_key = "sub-c-3183ed9c-3c2d-11e7-847e-02ee2ddab7fe")
##
##channel = "my_channel"
##message = "Hello"
##
##pubnub.publish(
## channel = channel,
## message = "Hello")
def publish_callback(result, status):
pass
# handle publish result, status always present, result if successful
# status.isError to see if error happened
pnconfig = PNConfiguration()
pnconfig.subscribe_key = "sub-c-3183ed9c-3c2d-11e7-847e-02ee2ddab7fe"
pnconfig.publish_key = "pub-c-5547bc05-fdd3-489e-b4bc-930fb835441d"
pnconfig.ssl = False
pubnub = PubNub(pnconfig)
pubnub.publish().channel("my_channel").message(["hello", "there"])\
.should_store(True).use_post(True).async(publish_callback)
##pubnub.subscribe().channels('my_channel').execute()
##pubnub.unsubscribe().channels("my_channel").execute()