Python,如何将状态/ update_with_media发布到Twitter?
发布时间:2020-12-30 09:32:36 所属栏目:Python 来源:互联网
导读:我能够在 Python中成功发布状态更新(推文): import urllibimport oauth2 as oauthtoken = oauth.Token(access_token,access_token_secret)consumer = oauth.Consumer(consumer_key,consumer_secret)client = oauth.Client(con
我能够在 Python中成功发布状态更新(推文): import urllib import oauth2 as oauth token = oauth.Token(access_token,access_token_secret) consumer = oauth.Consumer(consumer_key,consumer_secret) client = oauth.Client(consumer,token) data = {'status': 'hello world'} request_uri = 'https://api.twitter.com/1/statuses/update.json' resp,content = client.request(request_uri,'POST',urllib.urlencode(data)) 现在我想知道我需要改变什么才能用update_with_media发布图片? 解决方法最后,我得到了它的工作,并希望让那些正在努力解决这个问题的人知道我最终使用漂亮的Twython库轻松完成它,它很好地抽象了函数:from twython import Twython twitter = Twython( twitter_token = 'consumer_key',twitter_secret = 'consumer_secret',oauth_token = 'access_token',oauth_token_secret = 'access_token_secret' ) twitter.updateStatusWithMedia('/home/blah/projects/pathexample/static/example.png',status='hello!') (编辑:鄂州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- python – Django get_or_create和ManytoManyField
- python – 如何在selenium webdriver中使用变量通过xpath查
- 一个使用SimpleHTTPServer和SocketServer的简单的python服务
- 在Python Celery中,如何在连续的工作调用中持久保存对象?
- python – 是否有一个有意义的方法来使用发生器内的上下文管
- 如何判断是否已评估Django QuerySet?
- python – 在字符串列表中标记动态子字符串
- 如何在python代码中编写此算法?
- Python键入模块类型
- python – 使用Flask-WTForms字段描述呈现html标题属性