Permalink
Browse files

fix post bugs

  • Loading branch information...
1 parent ba90bd4 commit 8167b0152806dd066c8f66f769c6961921b5e48b @clsung committed May 23, 2011
Showing with 8 additions and 4 deletions.
  1. +1 −1 plurk-oauth/PlurkAPI.py
  2. +7 −3 plurk-oauth/PlurkOAuth.py
View
@@ -13,7 +13,7 @@ def authorize(self, access_key = None, access_secret = None):
def callAPI(self, path, options = None):
if not self._authorized:
self._oauth.authorize()
- return self._oauth.request(path, options)
+ return self._oauth.request(path, None, options)
if __name__ == '__main__':
import os
View
@@ -1,5 +1,6 @@
import oauth2 as oauth
import urlparse
+from urllib import urlencode
import httplib
class PlurkOAuth:
@@ -36,7 +37,7 @@ def authorize(self, access_token_key = None, access_token_secret = None):
verifier = self.get_verifier()
self.get_access_token(verifier)
- def request(self, url, params = None):
+ def request(self, url, params = None, data = None):
# Setup
client = oauth.Client(self.consumer)
@@ -46,8 +47,11 @@ def request(self, url, params = None):
req = self.__make_request__(self.baseURL + url, params)
# Get Request Token
- resp, content = client.request(self.baseURL + url, "POST",
- headers=req.to_header())
+ encodedContent = None
+ if data:
+ encodedContent = urlencode(data)
+ resp, content = client.request(self.baseURL + url, "POST",
+ headers=req.to_header(), body = encodedContent)
if resp['status'] != '200':
print content
raise Exception("Invalid response %s." % resp['status'])

0 comments on commit 8167b01

Please sign in to comment.