I donwloaded the rtweet package in r as there are more functions than tweetR, but the output keeps giving me an error saying that "auth" is not found. I am not sure how to input the api key and token because of the new update. Anyone know the code? I entered the tokens and keys the twitter api gave me but can't figure out how to get it to sync/run.
library(rtweet)
install.packages("ROAuth")
library(ROAuth)
## authenticate via access token
app = "statskenyon"
consumer_key = "my key"
consumer_secret = "consumer secret"
acess_token = "access token"
access_secret = "access secret"
auth <- rtweet_app("bearer token")
In the previous version of rtweet, after You have to save your tokens to an R object first.
your_token_name <- create_token(app = "statskenyon",
consumer_key = "my key",
consumer_secret = "consumer secret",
access_token = "access token",
access_secret = "access secret",
set_renv = TRUE
)
Then use it in a post_status().
post_tweet(
status = "my first rtweet #rstats",
token = your_token_name
)
In newer version, instead of using
auth <- rtweet_app("bearer token")
I suggest You to use rtweet_bot() function, since from your code you only have 4 keys.
your_new_token_name <- rtweet::rtweet_bot(
api_key = "my key",
api_secret = "consumer secret",
access_token = "access token",
access_secret = "access secret"
)
Then use it to post a status message
rtweet::post_tweet(
status = "your_status_message",
token = your_new_token_name
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.