python-twitter icon indicating copy to clipboard operation
python-twitter copied to clipboard

twitter.error.TwitterError: [{'code': 34, 'message': 'Sorry, that page does not exist.'}]

Open PythonCoderAS opened this issue 6 years ago • 16 comments

Whenever I make a request with the api to fetch Direct Messages api.GetDirectMessages(), it always throws me a twittererror with the message "Sorry, that page does not exist."

Traceback:

Traceback (most recent call last):
  File "C:/Users/neela/Desktop/Programs/python projects/Mine/DM Storage/login.py", line 13, in <module>
    logging.info(api.GetDirectMessages())
  File "C:\Program Files\Python36\lib\site-packages\twitter\api.py", line 2937, in GetDirectMessages
    data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
  File "C:\Program Files\Python36\lib\site-packages\twitter\api.py", line 4908, in _ParseAndCheckTwitter
    self._CheckForTwitterError(data)
  File "C:\Program Files\Python36\lib\site-packages\twitter\api.py", line 4928, in _CheckForTwitterError
    raise TwitterError(data['errors'])
twitter.error.TwitterError: [{'code': 34, 'message': 'Sorry, that page does not exist.'}]

I tried looking through #592 , but it was closed at Nov. 2018, and the new endpoints should have been implemented. There have been four months since the closure, and how has there not been enough time to update the API endpoints?

PythonCoderAS avatar Feb 03 '19 04:02 PythonCoderAS

+1 have this problem

esemeniuc avatar Feb 13 '19 00:02 esemeniuc

Honestly if I knew how a token was received and then requested to the API I could send a push request to fix it.

From: Eric Semeniuc [email protected] Sent: Tuesday, February 12, 2019 7:18 PM To: bear/python-twitter [email protected] Cc: PokestarFan [email protected]; Author [email protected] Subject: Re: [bear/python-twitter] twitter.error.TwitterError: [{'code': 34, 'message': 'Sorry, that page does not exist.'}] (#603)

+1 have this problem

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bear/python-twitter/issues/603#issuecomment-462999286 , or mute the thread https://github.com/notifications/unsubscribe-auth/ANSYJzAcOs2a_qH9R0eRvY1MXPRJVOLEks5vM1m2gaJpZM4af7zf . https://github.com/notifications/beacon/ANSYJxXycUJo_2EYaizlJqMN2dfwUxEDks5vM1m2gaJpZM4af7zf.gif


This email has been checked for viruses by AVG. https://www.avg.com

PythonCoderAS avatar Feb 13 '19 00:02 PythonCoderAS

here's a quick hack to be able to use json: https://github.com/TrustedCapsules/python-twitter/commit/e0c90859e136a833d5bf7264438718f1b0cf85c2

The DirectMessage class needs to be updated (see https://github.com/TrustedCapsules/python-twitter/blob/e0c90859e136a833d5bf7264438718f1b0cf85c2/twitter/models.py#L180)

esemeniuc avatar Feb 13 '19 02:02 esemeniuc

Hi, I tried the fix and it didn't work, I just get the following:

Traceback (most recent call last): File "[path_removed]/tweeting.py", line 13, in api.GetDirectMessages() File "[path_removed]/twitter/api.py", line 2942, in GetDirectMessages return [DirectMessage.NewFromJsonDict(x) for x in data] File "[path_removed]/twitter/api.py", line 2942, in return [DirectMessage.NewFromJsonDict(x) for x in data] File "[path_removed]/twitter/models.py", line 88, in NewFromJsonDict json_data = data.copy() AttributeError: 'str' object has no attribute 'copy'

theelk801 avatar Mar 19 '19 20:03 theelk801

@theelk801 You must use the return_json flag since the model hasnt been updated. Then you can manually manipulate the dict

esemeniuc avatar Mar 19 '19 20:03 esemeniuc

Oh, I see. Alright, I suppose that'll have to do for now. Thanks!

theelk801 avatar Mar 19 '19 21:03 theelk801

For anyone confused on how to implement the flag, it is api.GetDirectMessages(return_json=True) where api is the TwitterApi instance

PythonCoderAS avatar Mar 19 '19 22:03 PythonCoderAS

I'm getting the same error 34 when trying to get DMs from an authorized App, even when I'm using the return_json parameter. :-/

pacu avatar Aug 05 '19 20:08 pacu

I am still having the same error in accessing DMs and neither the return_json parameter nor that quick hack fix work :/

mdd423 avatar Nov 01 '19 04:11 mdd423

Hi guys, the Error is caused by the old version of pip package, in the pip version the function GetDirectMessages uses an old URL, you can change that for the new url. Step 1: find api.py file run pip show python-twitter and see the path

Step 2: find the old url in api.py, line 2922

Step 3: change that line with url = '%s/direct_messages/events/list.json' % self.base_url

DVRodri8 avatar Nov 26 '19 13:11 DVRodri8

@DVRodri8 So you mean update the package?

PythonCoderAS avatar Nov 27 '19 23:11 PythonCoderAS

Is there any kind of ETA or planning on getting this in the project?

kevr avatar Jun 19 '20 02:06 kevr

Hi guys, the Error is caused by the old version of pip package, in the pip version the function GetDirectMessages uses an old URL, you can change that for the new url. Step 1: find api.py file run pip show python-twitter and see the path

Step 2: find the old url in api.py, line 2922

Step 3: change that line with url = '%s/direct_messages/events/list.json' % self.base_url

This plus return_json=True made it work for me

sebastiansam55 avatar Aug 23 '20 18:08 sebastiansam55

Hi guys, the Error is caused by the old version of pip package, in the pip version the function GetDirectMessages uses an old URL, you can change that for the new url. Step 1: find api.py file run pip show python-twitter and see the path Step 2: find the old url in api.py, line 2922 Step 3: change that line with url = '%s/direct_messages/events/list.json' % self.base_url

This plus return_json=True made it work for me

Can you specify this?

chrischma avatar Oct 09 '21 08:10 chrischma

For anyone confused on how to implement the flag, it is api.GetDirectMessages(return_json=True) where api is the TwitterApi instance

@chrischma

sebastiansam55 avatar Oct 12 '21 11:10 sebastiansam55

{"errors":[{"code":34,"message":"Sorry, that page does not exist."}]}

digra1968 avatar Feb 27 '23 19:02 digra1968