我想使用html表单从我的硬盘上传图片:
Image file: <input name="imageupload" id="imageupload" type="file" />
然后,我使用以下方式将其上传到 Twitter:
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.
任何想法它来自于哪里?谢谢!