I used this this time
If you want to do ʻupdate_with_media () in Python 3.x, you need to modify ʻapi.py
as follows.
bod.append('Content-Disposition: form-data; name="%s"' % mediafield)
+ bod.append('Content-Transfer-Encoding: base64')
- body = '\r\n'.join(bod)
+ body = '\r\n'.join(bod).encode('utf-8')
https://github.com/sixohsix/twitter/issues/233
Also, if you are decoding the file with base64 when posting, you need to do something like data = base64.b64encode (f.read ()). Decode ("utf8", "ignore")
It may not be necessary if it is a normal image # Unconfirmed
When posting only a message, I could do it with keyword arguments, but when I did the same with ʻupdate_with_media ()`, I got an error. In this case I had to pass it as a dictionary
params = {"media[]": data,
"status": msg
}
tw.statuses.update_with_media(**params)
Recommended Posts