带有类和扭曲错误的探测。我该如何解决?

时间:2019-04-30 16:06:16

标签: tweepy

继续获取Twitter错误响应:状态代码= 400 我该如何解决

with open('twitter_credentials.json') as credentials_data:
    info = json.load(credentials_data)
    Api_key = info['API_KEY']
    Api_key_secret = info['API_KEY_SECRET']
    Access_token = info['ACCESS_TOKEN']
    Access_token_secret = info['ACCESS_TOKEN_SECRET']

class TwitterAuthenticator:
    def TwitterApplicationAuthentication(self):
        auth = OAuthHandler(Api_key, Api_key_secret)           
        auth.set_access_token(Access_token, Access_token_secret)
        api = API(auth) 

class TwitterClient:

    def __init__(self, twitter_user):
        self.auth = TwitterAuthenticator.TwitterApplicationAuthentication(self)
        self.twitter_client = API(self.auth)
        self.twitter_user = twitter_user

    def get_user_timeline_tweets(self,num_tweets):
        all_tweets = []
        for tweet in Cursor(self.twitter_client.user_timeline, id=self.twitter_user).items(num_tweets):
            tweets.extend(tweet)
        return all_tweets

if __name__ == '__main__':

    twitter_client = TwitterClient('elonmusk') 
    print(twitter_client.get_user_timeline_tweets(3))

运行最后一个代码,打印时出现错误。...

0 个答案:

没有答案