这是我获取关注者和更新状态的代码:
from twython import Twython,TwythonError
APP_KEY='mykey'
APP_SECRET='mysecret'
OAUTH_TOKEN='mytoken'
OAUTH_TOKEN_SECRET='mytokensecret'
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
followers = twitter.get_followers_ids(screen_name = "darcythegreat")
for follower_id in followers:
print follower_id
try:
twitter.update_status(status='My first status using Twython')
except TwythonError as e:
print e
这是LINK https://twitter.com/DarcyTheGreat到我的推特。
运行后我收到以下错误:
python tweet.py
previous_cursor
previous_cursor_str
next_cursor
ids
next_cursor_str
Twitter API returned a 401 (Unauthorized), An error occurred processing your request.
您能告诉我我缺少哪些步骤吗?
出现 401 的原因有多种,其中一些与您编写的代码无关。一个常见的原因是您和 Twitter 服务器之间的时钟时间不同。以下是 Twitter OAuth 常见问题解答的链接:https://developer.twitter.com/en/docs/authentication/faq https://developer.twitter.com/en/docs/authentication/faq
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)