我想使用 html 表单从我的硬盘上传一张图片:
Image file: <input name="imageupload" id="imageupload" type="file" />
然后我把它上传到推特:
image=self.request.get('imageupload')
image2=base64.b64encode(image)
twitapi.Update_profile_image(image=image2)
给定 twitapi.Update_profile_image:
def Update_profile_image(self,image):
if not self._oauth_consumer:
raise TwitterError("The twitter.Api instance must be authenticated.")
url = '%s/account/update_profile_image.json' % (self.base_url)
data = {'image':image}
json = self._FetchUrl(url, post_data=data)
data = self._ParseAndCheckTwitter(json)
return data
给定来自 twitter-api 的 _FetchUrl
我总是得到
TwitterError: There was a problem with your picture. Probably too big.
有什么想法吗?谢谢!