The Twitter API
allows you to add media to your tweet via their update_with_tweet
method.
I am using Sinatra
and have my Twitter
configurations all set up. I am able to succesfully post tweets with my app.
My app reads a webpage, extracts the photos from that page, and then is supposed to individually post them to Twitter. I am successfully extracting the photos from the page using Nokogiri
.
But, I am having trouble converting those photos into a media type that Twitter
will allow. Because I am also using the uri
gem, given this example: photo_url = "placekitten.com/300/300"
, I am able to call media = open(photo_url)
and this returns a StringIO
.
But, when I try posting that newly stored media with my post to Twitter
I am given the error that The IO object for media must respond to to_io (Twitter::Error::UnacceptableIO)
.
I am trying to figure out how to correctly format/call the image so that I can successfully post it to Twitter.