Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct Message #37

Open
sharma-ji opened this issue Jul 9, 2018 · 1 comment
Open

Direct Message #37

sharma-ji opened this issue Jul 9, 2018 · 1 comment

Comments

@sharma-ji
Copy link

What about Direct Message API?

@takinbo
Copy link

takinbo commented Oct 29, 2018

@sharma-ji it doesn't appear that the library directly supports posting a JSON payload to the Twitter API endpoint for direct messages and that's why you wouldn't be able to do so without a hack. Here's a snippet I created for getting around this:

params = {'event': {'type': 'message_create',
                    'message_create': {
                        'message_data': {'text': message},
                        'target': {'recipient_id': user_id}}}}

path = client.api.direct_messages.events.new.get_path()
url = client.construct_resource_url(path)
response = client.make_api_call('POST', url, json=params)
status = client.handle_response('POST', response)

client is the UserClient object you would have created previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants