@@ -28,7 +28,7 @@ def get_pad_content(self, padId, revision='', response_format='txt', asUser=''):
28
28
api_link = 'pad/%s/content' % padId
29
29
if revision != '' :
30
30
api_link += revision
31
- api_link += '.%s' % format
31
+ api_link += '.%s' % response_format
32
32
params = {}
33
33
if asUser != '' :
34
34
params ['asUser' ] = asUser
@@ -115,6 +115,7 @@ def site_options(self):
115
115
return self .do_api_request (api_link , 'GET' )
116
116
117
117
def do_api_request (self , path , method , post_data = {}, body = '' , content_type = 'text/plain' ):
118
+ method = method .upper ()
118
119
hackpad = {}
119
120
try :
120
121
api_method = urljoin ('https://%s.hackpad.com/api/1.0/' % self .sub_domain , path )
@@ -127,7 +128,7 @@ def do_api_request(self, path, method, post_data={}, body='', content_type='text
127
128
params [key ] = post_data [key ]
128
129
consumer = oauth2 .Consumer (self .consumer_key , self .consumer_secret )
129
130
params ['oauth_consumer_key' ] = consumer .key
130
- req = oauth2 .Request (method = 'GET' , url = api_method , parameters = params )
131
+ req = oauth2 .Request (method = method , url = api_method , parameters = params )
131
132
signature_method = oauth2 .SignatureMethod_HMAC_SHA1 ()
132
133
req .sign_request (signature_method , consumer , None )
133
134
api_link = req .to_url ()
@@ -138,7 +139,7 @@ def do_api_request(self, path, method, post_data={}, body='', content_type='text
138
139
headers = {'Content-Type' : content_type },
139
140
verify = False
140
141
)
141
- hackpad = r .json
142
+ hackpad = r .json ()
142
143
else :
143
144
if len (post_data .keys ()) > 0 :
144
145
r = requests .get (
@@ -153,7 +154,10 @@ def do_api_request(self, path, method, post_data={}, body='', content_type='text
153
154
headers = {'Content-Type' : 'text/plain' },
154
155
verify = False
155
156
)
156
- hackpad = r .json
157
+ try :
158
+ hackpad = r .json ()
159
+ except :
160
+ hackpad = r .content
157
161
except :
158
162
print sys .exc_info ()[0 ]
159
163
0 commit comments