Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add signin_url method

  • Loading branch information...
commit 5297ea98d0cfcff8acac045979833439539017a0 1 parent ad787ba
@abh authored
Showing with 20 additions and 4 deletions.
  1. +20 −4 yellowbot.py
View
24 yellowbot.py
@@ -1,5 +1,6 @@
import json, urllib, urllib2, time
import hashlib, hmac
+from urlparse import urlparse
class YellowBot():
@@ -8,9 +9,10 @@ def __init__(self, **args):
assert args.get('api_key'), "Missing api_key parameter"
assert args.get('api_secret'), "Missing api_secret parameter"
- if not args.get("server"):
- args["server"] = 'www.yellowbot.com'
+ if not args.get('server'):
+ args['server'] = 'www.yellowbot.com'
+ self.server = args['server']
self.api_base = 'http://' + args['server'] + "/api/"
self.api_key = args['api_key']
self.api_secret = args['api_secret']
@@ -25,7 +27,17 @@ def call(self, method, **args):
data = json.loads(api_data)
return data
- def _request(self, method, args):
+ def signin_url(self, **args):
+ domain = args.get('domain');
+ if not domain:
+ domain = self.domain
+
+ url = "http://" + domain + "/signin/partner"
+ args = self._query_args(args)
+ url += "?" + urllib.urlencode(args)
+ return url
+
+ def _query_args(self, args):
args.update({
'api_key': self.api_key,
'api_ts' : str(int(time.time()))
@@ -35,13 +47,17 @@ def _request(self, method, args):
'api_sig': self._signature(args)
})
+ return args
+
+ def _request(self, method, args):
+ args = self._query_args(args)
r = urllib2.Request( url = self.api_base + method, data = urllib.urlencode(args) )
return r
def _signature(self, args):
-
+
parameters = ""
if args:
Please sign in to comment.
Something went wrong with that request. Please try again.