import tweepy

# 你的Twitter API Key
consumer_key = 'your_consumer_key'
consumer_secret = 'your_consumer_secret'
access_token = 'your_access_token'
access_token_secret = 'your_access_token_secret'

# 设置API访问
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

# 检查用户是否转发了推文
def check_retweet(username, tweet_id):
    try:
        # 获取用户的转发列表
        retweets = api.retweets(tweet_id)
        for retweet in retweets:
            if retweet.user.screen_name == username:
                return True
        return False
    except tweepy.TweepError as e:
        print(f"Error: {e}")
        return False

# 使用示例
username = 'example_user'
tweet_id = '1234567890123456789'  # 你的推文ID
is_retweeted = check_retweet(username, tweet_id)
print(f"{username} has {'retweeted' if is_retweeted else 'not retweeted'} the tweet.")

https://developer.x.com/en/docs/twitter-api/tweets/retweets/introduction
https://developer.twitter.com/apitools/api?endpoint=%2F2%2Fusers%2F%7Bid%7D%2Fretweets&method=post