Created
September 28, 2018 16:12
-
-
Save semifor/9fc557820308a7dcca485a0adb669e9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Snippet demonstrating how to post a direct message with an attached image | |
# using the new Twitter direct message API | |
# First upload the image | |
my $media = $client->upload_media({ | |
media => [ $image_path_name ], | |
media_category => 'dm_image' | |
}); | |
# Attach the image in message_data | |
my $r = $client->post('direct_messages/events/new', { | |
-to_json => { | |
event => { | |
type => 'message_create', | |
message_create => { | |
target => { recipient_id => $user_id }, | |
message_data => { | |
text => $text, | |
attachment => { | |
type => 'media', | |
media => { id => $media->{id} }, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment