Fumiya
Fumiya

Reputation: 127

Rails4 How can I tweet with a picture from a website with sferik / twitter gem?

I know i can tweet with update method like client.update("I'm tweeting with @gem!") but how can i tweet with a picture from a website? Can I use update_with_media method with URL?

Upvotes: 2

Views: 728

Answers (1)

Juan E.
Juan E.

Reputation: 1819

The update_with_media method expects an image file

# @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
# ...
# ...
def update_with_media(status, media, options = {})

Source: https://github.com/sferik/twitter/blob/master/lib/twitter/rest/tweets.rb#L224

To use an URL of a website for the media you should use another gem that captures a URL to an image (e.g. https://github.com/csquared/IMGKit) and then send that image with the update_with_media method.

Upvotes: 2

Related Questions