Home>

I want to get the timeline using python,
At the end I get an error.
I'm wondering if this is the correct form because the access token I got is made up of only Xs. Is it properly acquired?
Also, since it is Traceback, is it the cause of the last status_list = api.home_timeline()?

python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import tweepy
>>>consumer_key = ""
>>>consumer_secret = ""
>>>access_token = "×××××××××××××××××××××"
>>>access_token_secret = "×××××××××××××××××××××××××"
>>>auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
>>>auth.set_access_token(access_token,access_token_secret)
>>>api = tweepy.API(auth)
>>>status_list = api.home_timeline()
Traceback (most recent call last):
  File "<stdin>", line 1, in<module>
  File "C:\Users\Shun\Documents\python\lib\site-packages\tweepy\binder.py", line 250, in _call
    return method.execute()
  File "C:\Users\Shun\Documents\python\lib\site-packages\tweepy\binder.py", line 233, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{'code': 89,'message':'Invalid or expired token.'}]


  • Answer # 1

    Make sure you read the details of the error.

    tweepy.error.TweepError: [{'code': 89,'message':'Invalid or expired token.'}]

    Error: Code 89, using invalid or expired token! So change it!

    about it. I'm not very familiar with this API, but why not revisit the token?
    Although it is in English, the following sites may be helpful.
    https://stackoverflow.com/questions/46062142/tweepy-tweeperror-code-89-invalid-or-expired-token

  • Answer # 2

    If you have forgotten your token,RegenerateYou must either authenticate or verify your token.

    Click here for authentication with tweepy.
    http://docs.tweepy.org/en/v3.8.0/auth_tutorial.html
    This is an ordinary web authentication procedure.
    halfwayraw_inputIs a Python 2 functioninputLet's.