r twitter userTimeline错误oauth

问题描述:

我正在尝试使用twitteR库检索R中的许多用户的推文。 setup_twitter_oauth和一些其他功能,如getUser,getFollowers都可以正常工作。我的问题是当我尝试在lapply(或for循环)中使用userTimeline时,它给了我一个OAuth身份验证错误。 (正确运行userTimeline。)在返回错误后,我使用getCurRateLimitInfo(),并且所有命令都显示可用的限制。r twitter userTimeline错误oauth

这是我跑过的代码片段。从(与回溯)lapply运行

... 
library("twitteR") 
setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret) 
my_user <- getUser("my_twitter_name") 
my_followers <- my_user$getFollowers(n=100) 
tweets <- unlist(lapply(my_followers, function(x) userTimeline(x$id, n=100))) 

错误:

Error in twInterfaceObj$doAPICall(cmd, params, method, ...) : 

OAuth authentication error: 
This most likely means that you have incorrectly called setup_twitter_oauth()' 
10 stop("OAuth authentication error:\nThis most likely means that you have incorrectly called setup_twitter_oauth()'") 
9 twInterfaceObj$doAPICall(cmd, params, method, ...) 
8 doPagedAPICall(cmd, n, params, ...) 
7 lapply(X = X, FUN = FUN, ...) 
6 sapply(doPagedAPICall(cmd, n, params, ...), buildStatus) 
5 statusBase(cmd, params, n, 3200, ...) 
4 userTimeline(x$id, n = 100) 
3 FUN(X[[i]], ...) 
2 lapply(my_followers, function(x) userTimeline(x$id, n = 100)) 
1 unlist(lapply(my_followers, function(x) userTimeline(x$id, n = 100))) 

我没有抬头OAuth错误,它似乎setup_twitter_oauth时多发生,而不是其他的功能。几个问题:

  • 是什么导致了这个错误以及如何解决它?
  • 我的最终目标是从追随者或持有追随者用户名和推文的数据框中获取推文向量。有没有更有效的方法来实现这一目标?

谢谢!

我有同样的问题。删除受保护的用户解决了它。 尝试类似my_followers <- my_followers[protected == FALSE],它应该工作。