Search code examples
pythontwitterpython-twitter

Python script that gets my latest tweet stopped working on my server


Consider the following code:

import twitter
api = twitter.Api()
most_recent_status = api.GetUserTimeline('nemesisdesign')[0].text

On my server (nemesisdesign.net) stopped working a few days ago.

If I try the same code from my own machine it works fine.

This is the stack trace:

>>> most_recent_status = api.GetUserTimeline('nemesisdesign')[0].text
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "build/bdist.linux-i686/egg/twitter.py", line 1414, in GetUserTimeline
    json = self._FetchUrl(url, parameters=parameters)
  File "build/bdist.linux-i686/egg/twitter.py", line 2032, in _FetchUrl
    url_data = opener.open(url, encoded_post_data).read()
  File "/usr/local/lib/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/local/lib/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 404: Not Found

Any hint? I have no clue ... :-(


Solution

  • Twitter recently deprecated their old API. Is it possible you're still using it?

    Note, the change should require you to update to the new OAuth-based authentication model. If your site is accessing tweets for a single account, you can use the process in https://dev.twitter.com/docs/auth/oauth/single-user-with-examples to avoid prompting the user for access.