forked from DavidCDean/salesforce-streaming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
29 lines (19 loc) · 698 Bytes
/
Copy pathdemo.py
File metadata and controls
29 lines (19 loc) · 698 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
__author__ = 'David C. Dean'
import salesforce_streaming as sf
import time
from demo_config import user, passwd, clid, clscrt
auth = sf.OAuth(username=user, password=passwd, client_id=clid, client_secret=clscrt)
print('\nAuthenticating...')
if auth.request_token():
print('\nHandshaking...')
stream_api = sf.StreamingAPI(instance=auth.get_instance(), token=auth.get_token())
if stream_api.handshake():
print('\nSubscribing...')
stream_api.subscribe('/topic/AllTestObjs')
print('\nConnecting...')
while True:
time.sleep(2)
stream_api.connect()
print('\nReconnect...')
else:
print('Token Request Failed.')