【发布时间】:2022-01-13 08:06:16
【问题描述】:
为什么我可以创建一条推文并点赞一条没有 401 错误的推文?当我尝试搜索推文时,我得到了 401?
这是我的 create_tweet.py 文件(工作正常)
import tweepy
import config
# calling a client
client = tweepy.Client(
consumer_key=config.consumer_key,
consumer_secret=config.consumer_secret,
access_token=config.access_token,
access_token_secret=config.access_token_secret
)
response = client.create_tweet(text='twitter api testoooor')
print(response)
但我的 search.py 文件不断收到 401 错误:
import tweepy
import config
# calling a client
client = tweepy.Client(
consumer_key=config.consumer_key,
consumer_secret=config.consumer_secret,
access_token=config.access_token,
access_token_secret=config.access_token_secret
)
response = client.search_recent_tweets(query=query, max_results=10)
for tweet in response.data:
print(tweet.id)
真的很奇怪,create_tweet.py 没有收到 401 错误,但我的 search.py 文件却是。
【问题讨论】:
标签: python authentication error-handling tweepy