Direct Message
sharma-ji opened this issue · 1 comments
sharma-ji commented
What about Direct Message API?
takinbo commented
@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.