Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending an image to Twitter in R using the twitterR package

Tags:

r

twitter

I'm fairly new to programming and can't figure out how to submit an image to Twitter using the twitterR package. I want to submit an image from a website to Twitter hourly.

This is my script so far. I need help with the command to send an image to Twitter!

library(twitteR)
library(httr)


ckey <- "X"
csecret <- "X"
atoken <- "X"
asecret <- "X"

setup_twitter_oauth(ckey, csecret, atoken, asecret)

tweet("")
like image 668
Maximilian Janetzki Avatar asked Jan 25 '26 18:01

Maximilian Janetzki


1 Answers

There is a parameter in tweet() and updateStatus() called mediaPath which you can use to submit images. Try something like:

tweet("some status", mediaPath = "url-to-image.jpg")

Edit: media needs to be local or if it's a URL then it needs to have been uploaded to Twitter, which can also be done with the API, but not through twitteR I believe.

like image 178
Oliver Frost Avatar answered Jan 28 '26 11:01

Oliver Frost



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!