通过python将图片发布到Twitter [英] Publishing pictures to Twitter via python

查看:42
本文介绍了通过python将图片发布到Twitter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人使用 python 的 twitter 模块(https://github.com/sixohsix/twitter/tree/master) 可以在 Twitter 帐户上发布图片吗?将文本发布到状态时一切正常,但我不知道如何发布图片.感谢您的帮助.

Is anyone using the twitter module for python (https://github.com/sixohsix/twitter/tree/master) able to publish pictures on twitter account? Everything works fine with publishing text to status, but I couldn't figure how to publish pictures. Thanks for the help.

按照评论中的建议添加我的代码(谢谢!):

Adding my code, as suggested in the comments (thanks for that!):

import twitter

t = twitter.Twitter(auth=twitter.OAuth('PAR1', 'PAR2','PAR3', 'PAR4')) #autentication is fine.

#t.statuses.update(status="Hello World!") #this command works fine!

t.updateStatusWithMedia('http://url_of_image', status="Hello World!") #that's what I need to do.

推荐答案

如果您使用的是外部 twitter 模块,我假设您可以接受安装其他外部库.您可以尝试 tweetphoto 通过 API 上传图片.您可以在此处弄清楚.

If you are using the external twitter module, I assume that installing other external libraries is acceptable to you. You could try tweetphoto to upload images via an API. You can figure it out here.

这篇关于通过python将图片发布到Twitter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆