How to set User-Agent in python-twitter?

試著忘記壹切 提交于 2019-12-25 01:46:11

问题


i'm writing a small script to tweet messages from the monitoring systems. The only issue i ran into so far is that i can't set the User-Agent correctly, all tweets show up as "from API" which ain't a huge deal but i wonder what I'm doing wrong. An example to reproduce this behavior:

import sys
import twitter

USERNAME="twitteruser"
PASSWORD="twitterpassword"

api = twitter.Api(username=USERNAME, password=PASSWORD)
api.SetUserAgent("Monitor")
api.SetXTwitterHeaders("Monitor", None, "0.1")
status = api.PostUpdate("Test")

I'm running Python 2.6.4 on Ubuntu 9.10 with python-twitter 0.6

Any ideas ? :-)


回答1:


In order to get Twitter to recognize your application you have to use OAuth nowadays and register your application.

See this FAQ entry and Twitter's application registration form.



来源:https://stackoverflow.com/questions/1803669/how-to-set-user-agent-in-python-twitter

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