你好,我有以下代码,不明白错误。我可以找到用户arconic并从帐户中提取推文,但我不知道为什么我找不到关注者。有什么想法吗?
setup_twitter_oauth(consumer_key,
consumer_secret,
access_token,
access_secret)
> getUser("@brent_ferrier")
[1] "brent_ferrier"
> getUser("@arconic")
[1] "arconic"
> getUser("@brent_ferrier")$getFollowers(retryOnRateLimit=180)
$`80172448`
[1] "givesuponlove"
$`256679525`
[1] "katiewebster30"
> getUser("@arconic")$getFollowers(retryOnRateLimit=180)
Error in twInterfaceObj$doAPICall(paste("users", "show", sep = "/"), params = params, :
client error: (404) Not Found
> tweets<-userTimeline("arconic",n=3200)
> length(tweets)
[1] 159
答案 0 :(得分:4)
不推荐使用twitteR,而选择rtweet。所以我可以告诉你什么对rtweet有用:
## v0.4.0 published on CRAN today
install.packages("rtweet")
## load pkg
library(rtweet)
## if your token is already saved as .httr-oauth then
## it should work or you can checkout
#?create_token
## Even better save token as envir var instructions here:
#vignettes("auth", "rtweet")
## there's actually a built-in token in rtweet as well but
## it won't be as reliable as your own token. it's mostly
## there to let people test drive the pkg.
## to get followers for a user
flw <- get_followers("brent_ferrier")
## the same basic way to get friends
fds <- get_friends("brent_ferrier")
## lookup users data for both followers and friends
usrs <- lookup_users(c(flw$user_id, fds$user_id))
## or timeline of a user's tweets
bf <- get_timeline("brent_ferrier", n = 3200)
## create a neat time series plot of tweets
ts_filter(bf, "days") %>%
ts_plot(lwd = 2, theme = "spacegray",
main = "Tweets from brent_ferrier",
subtitle = "Collected using rtweet")
您还可以在rtweet包网站上查看包文档:http://mkearney.github.io/rtweet