如何在 python-twitter 中设置 User-Agent? [英] How to set User-Agent in python-twitter?

查看:41
本文介绍了如何在 python-twitter 中设置 User-Agent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小脚本来发送来自监控系统的消息.到目前为止我遇到的唯一问题是我无法正确设置用户代理,所有推文都显示为来自 API",这没什么大不了的,但我想知道我做错了什么.重现此行为的示例:

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")

我在 Ubuntu 9.10 和 python-twitter 0.6 上运行 Python 2.6.4

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

有什么想法吗?:-)

推荐答案

为了让 Twitter 识别您的应用程序,您现在必须使用 OAuth 并注册您的应用程序.

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

请参阅此常见问题解答条目Twitter 的申请注册表.

这篇关于如何在 python-twitter 中设置 User-Agent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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