Twython - How to update status with media url

£可爱£侵袭症+ 提交于 2019-12-05 20:10:14

Glad to see you found an answer! There's a similar problem that we handled recently in a repo issue - basically, you can do the following with StringIO and passing it directly to twitter.post like you did:

from StringIO import StringIO
from twython import Twython

t = Twython(...)
img = open('img_url').read()
t.post('/statuses/update_with_media', params = {'status': 'Testing New Status'}, files = {
    'media': StringIO(img)
    # 'media': ('OrThisIfYouWantToNameTheFile.lol', StringIO(img))
})

This isn't a direct answer to your question, so I'm not expecting any vote or anything, but figured it's seemingly useful to some people and somewhat related so I'd drop a note.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!