Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix: The problem that url contain :id/:username.
  • Loading branch information
elleryq committed May 13, 2011
1 parent 7a3152c commit 7c100ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions pixnetlib/__init__.py
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
pass

def cmd(self, args):
def execute(parameters=None, method="GET"):
def execute(key=None, parameters=None, method="GET"):
if not parameters:
parameters = {}

Expand Down Expand Up @@ -59,6 +59,9 @@ def execute(parameters=None, method="GET"):
else:
p = True

if key:
url += '/%s' % key

body = None
param_encoded = urlencode(parameters)
if len(param_encoded):
Expand All @@ -68,10 +71,13 @@ def execute(parameters=None, method="GET"):
body = param_encoded
# headers['Content-Type'] = 'application/x-www-form-urlencoded'
elif method == "GET":
if key:
url = url[:-1]

if len(param_encoded):
url += '?' + param_encoded

print 'url is %s ' % url
#print 'url is %s ' % url
# print 'body is %s ' % body
http = httplib2.Http()
resp, content = http.request(url, method=method, body=body)
Expand Down
4 changes: 2 additions & 2 deletions test.py
Expand Up @@ -6,8 +6,8 @@

def main( arg ):
pixnet=Pixnet()
print( pixnet.get_users_elleryq() )
print( pixnet.get_album_sets( {'user': 'elleryq' }) )
print( pixnet.get_users( "elleryq", {} ) )
print( pixnet.get_album_sets( parameters={'user': 'elleryq' }) )

if __name__ == "__main__":
main(sys.argv[1:])
Expand Down

0 comments on commit 7c100ab

Please sign in to comment.