You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
A little follow-up on this... It is possible that the Twitter API returns in error and that 'event' is not returned in the response. Trying to create the DirectMessage object as the response of the PostDirectMessage call will then fail:
This happens, for example, when attempting to send a direct message to a user that is not following you.
When setting return_json=True, the returned data will then be something like this:
{'errors': [{'code': 150,
'message': 'You cannot send messages to users who are not following you.'}]}
Clearly 'event' is missing.
I think the return data of the call to the Twitter API needs to be checked for cases like this, before naively trying to create the DirectMessage object.
UPDATE: actually it looks like this line is simply missing after calling the Twitter API:
In reference to issue: #587
A little follow-up on this... It is possible that the Twitter API returns in error and that 'event' is not returned in the response. Trying to create the DirectMessage object as the response of the PostDirectMessage call will then fail:
This code fails with a
KeyError: 'event'
.This happens, for example, when attempting to send a direct message to a user that is not following you.
When setting return_json=True, the returned data will then be something like this:
Clearly 'event' is missing.
I think the return data of the call to the Twitter API needs to be checked for cases like this, before naively trying to create the DirectMessage object.
UPDATE: actually it looks like this line is simply missing after calling the Twitter API:
The text was updated successfully, but these errors were encountered: