Search code examples
pythonapitwittersocial-networkingstatus

python twitter api getting status


I am trying to get a recent status of a twitter user. I type in the following:

>>> from twitter import *
>>> t = Twitter(auth=OAuth(...))
>>> t.statuses.friends_timeline(id="StephenAtHome")

I get the following error at the last line:

Traceback (most recent call last):
  File "<pyshell#20>", line 1, in <module>
    t.statuses.friends_timeline(id="StephenAtHome")
  File "twitter\api.py", line 204, in __call__
    return self._handle_response(req, uri, arg_data, _timeout)
  File "twitter\api.py", line 235, in _handle_response
    raise TwitterHTTPError(e, uri, self.format, arg_data)
TwitterHTTPError: Twitter sent status 404 for URL: 1.1/statuses/friends_timeline/StephenAtHome.json using parameters (oauth_consumer_key=i1xQ3YKmmUI9pKlYDmSPeA&oauth_nonce=12051576929978547960&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1371245218&oauth_token=1517563807-75iFGXWHxMvzzsqrIs5W4tCb4OwFG4eisnDYRst&oauth_version=1.0&oauth_signature=m0LDp%2FdkJLMr3sHPnFQkLKlDTrE%3D)
details: {"errors":[{"message":"Sorry, that page does not exist","code":34}]}

How do I fix this error. I know that the page exists


Solution

  • The problem is that twitter API was upgraded to 1.1 version and friends_timeline was deprecated (see docs). Use home_timeline instead (user_timeline should work but doesn't):

    t.statuses.home_timeline(user_id="gvanrossum")
    

    Hope that helps.