NOTICE: Based on current web trends and our own usage data, PubNub's Python Twisted SDK is deprecated as of May 1, 2019. Deprecation means we will no longer be updating the Python Twisted SDK but will continue to support users currently using it. Please feel free to use our other Python SDK offerings as they will continue to be supported and maintained. If you would like to use the Python Twisted SDK specifically, we would love to work with you on keeping this project alive!
pubnub = Pubnub(publish_key="demo", subscribe_key="demo")
pnconf = PNConfiguration() pnconf.subscribe_key = 'demo' pnconf.publish_key = 'demo' pubnub = PubNub(pnconf)
V3accepts a callback as a parameter to announce when
V4switches to the listener pattern for
status. Please refer to the listener documentation to get started http://www.pubnub.com/docs/python-twisted/api-reference-publish-and-subscribe#listeners
Transactional requests (everything but subscribe, unsubscribe, presence) are now invoking using builders
errorcallbacks as arguments:
def callback(result): print(result) def errback(error): print(error) pubnub.publish('ch', 'Hi', callback=callback, error=errback)
envelope = yield pubnub.publish().channel('ch').message('Hi').deferred()
V3exposes subscribe callbacks via method params.
V4exposes the functionality via listeners.
V3returned different data structures based on request params.
V4has standardized payload. Please refer to documentation http://www.pubnub.com/docs/python-twisted/api-reference-storage-and-playback#history_returns.
V4returns a status object for each transactional request in the envelope and in the status portion of a listener or a callback.