简体   繁体   中英

How to set User-Agent in python-twitter?

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 ? :-)

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM