gpt4 book ai didi

python - 将 SSL 验证与 Tweepy 结合使用

转载 作者:行者123 更新时间:2023-11-28 17:42:20 32 4
gpt4 key购买 nike

去年,我使用 Python 脚本更新我的 Twitter 状态,但由于 Twitter 现在需要 SSL 验证,脚本失败并显示以下内容:

Tweepy.error.TweepError: [{'message': 'SSL is required', 'code': 92}]

脚本非常简单,如下所示。

# Consumer keys and access tokens, used for OAuth  
consumer_key = 'type in your consumer key here'
consumer_secret = 'type in your consumer secret here'
access_token = 'type in your access token here'
access_token_secret = 'type in your access token secret here'

# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

# Creation of the actual interface, using authentication
api = tweepy.API(auth)

if len(sys.argv) >= 2:
tweet_text = sys.argv[1]

else:
tweet_text = "Still messing about with tweepy and twitter API. :)"

if len(tweet_text) <= 140:
api.update_status(tweet_text)
else:
print "tweet not sent. Too long. 140 chars Max."

如有任何帮助,我们将不胜感激。谢谢。

最佳答案

我遇到了类似的问题,但通过从 the tweepy GitHub repo 安装 tweepy 设法解决了这个问题

git clone https://github.com/tweepy/tweepy.git
python setup.py install

但是,您尝试开始工作的项目很可能是在 Twitter REST API 为 v1 时编写的。因此,您可能会看到一个新错误:

tweepy.error.TweepError: [{'message': 'The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.', 'code': 64}]

关于python - 将 SSL 验证与 Tweepy 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22466801/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com