What should be the format for the parameter: media
, in the call below, for updating with multiple images.
def twitter_status_update_with_media (twitter_client, text, media, opts)
twitter_client.update_with_media(self.text, media, opts)
end
For a single image, File.new(filepath)
works fine..
To attach multiple images to a tweet, you first need to upload the images using the upload
method:
media_ids = %w(image1.png image2.png image3.png image4.png).map do |filename|
Thread.new do
twitter_client.upload(File.new(filename))
end
end.map(&:value)
This will return media IDs, which you can pass into the media_ids
parameter (as a comma-separated string) of the update
method.
twitter_client.update("Tweet text", :media_ids => media_ids.join(','))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With