aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/3.3/Pubnub.py23
-rw-r--r--python/3.3/here-now-example.py33
-rwxr-xr-xpython/3.3/publish-example.py2
3 files changed, 44 insertions, 14 deletions
diff --git a/python/3.3/Pubnub.py b/python/3.3/Pubnub.py
index e2b573f..5df77d5 100644
--- a/python/3.3/Pubnub.py
+++ b/python/3.3/Pubnub.py
@@ -25,27 +25,24 @@ class Pubnub(PubnubCore):
publish_key,
subscribe_key,
secret_key = False,
+ cipher_key = False,
ssl_on = False,
origin = 'pubsub.pubnub.com',
pres_uuid = None
) :
super(Pubnub, self).__init__(
- publish_key,
- subscribe_key,
- secret_key,
- ssl_on,
- origin,
- pres_uuid
+ publish_key = publish_key,
+ subscribe_key = subscribe_key,
+ secret_key = secret_key,
+ cipher_key = cipher_key,
+ ssl_on = ssl_on,
+ origin = origin,
+ uuid = pres_uuid
)
- def _request( self, request, origin = None, encode = True, params = None, callback = None ) :
+ def _request( self, request, callback = None ) :
## Build URL
- url = (origin or self.origin) + '/' + "/".join(
- encode and self._encode(request) or request
- )
- ## Add query params
- if params is not None and len(params) > 0:
- url = url + "?" + "&".join(params)
+ url = self.getUrl(request)
## Send Request Expecting JSONP Response
try:
diff --git a/python/3.3/here-now-example.py b/python/3.3/here-now-example.py
new file mode 100644
index 0000000..261500a
--- /dev/null
+++ b/python/3.3/here-now-example.py
@@ -0,0 +1,33 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+## -----------------------------------
+## PubNub 3.1 Real-time Push Cloud API
+## -----------------------------------
+
+import sys
+from twisted.internet import reactor
+from Pubnub import Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub( publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+crazy = 'hello_world'
+
+
+print pubnub.here_now( {
+ 'channel' : crazy
+})
+
diff --git a/python/3.3/publish-example.py b/python/3.3/publish-example.py
index 725df0b..c97034b 100755
--- a/python/3.3/publish-example.py
+++ b/python/3.3/publish-example.py
@@ -1,7 +1,7 @@
from Pubnub import Pubnub
## Initiate Class
-pubnub = Pubnub( 'demo', 'demo', None, False )
+pubnub = Pubnub( publish_key='demo', subscribe_key='demo', ssl_on=False )
## Publish Example
info = pubnub.publish({