尝试从 Twitter 流式传输时出错 API
Errors when trying to stream from the Twitter API
我正在尝试使用 StreamR 和本指南从 Twitter 流式传输数据 https://github.com/pablobarbera/streamR
它最近工作正常,但现在我在尝试流式传输任何数据时遇到此错误;
library(ROAuth)
library(streamR)
my_oauth <- list(consumer_key = "...",
consumer_secret = "...",
access_token="...",
access_token_secret = "...")
getUsers(screen_names="LSEnews", oauth = my_oauth)
#Error in function (type, msg, asError = TRUE) :
#Unknown SSL protocol error in connection to api.twitter.com:443
When I try to stream tweets the connection closes after 0 second
filterStream(file.name="trump-tweets.json", track="trump", timeout=120, oauth=my_oauth)
#Capturing tweets...
#Connection to Twitter stream was closed after 0 seconds with up to 0 tweets #downloaded.
我已经在 Twitter 开发者网站上重新生成了我的客户密钥和访问令牌,并且还创建了一个新的应用程序。我还尝试更新 ROAuth 和 streamR 包。但是,当我尝试从 github 更新 streamR 时,出现此错误(我之前已经安装过该软件包,没有任何问题);
library(devtools)
#Loading required package: usethis
devtools::install_github("pablobarbera/streamR/streamR")
#Error in rethrow_call(c_processx_exec, command, c(command, args), stdin, :
# Incorrect number of arguments (16), expecting 14 for 'processx_exec'
这让我得到了这个答案,我可能需要更新 processx 包
https://github.com/r-lib/devtools/issues/2077
我已更新
install.packages("processx")
但这并没有解决问题,当我尝试从 Github 更新 StreamR 包时,仍然出现相同的错误。我还尝试通过 CRAN 安装 streamR-package;
install.packages("streamR")
install.packages("ROAuth")
但这并没有解决我关于流式推文的主要问题。
感谢任何帮助,谢谢!
我能够成功 运行 下面的代码(证明这确实是您的设置问题,并且 API 或包本身没有任何变化)。
几个注意事项:
- 我安装了 github 版的 streamR
- 请注意,我无法 运行 函数
getUsers
;我怀疑该功能来自 CRAN 版本
- 我已经包含了
sessionInfo()
的输出;也许如果您确保您拥有与我相同的包版本和 R 版本,您将能够 运行 成功或至少引导您朝着 的方向前进
library(streamR)
#> Loading required package: RCurl
#> Loading required package: bitops
#> Loading required package: rjson
#> Loading required package: ndjson
my_oauth <- list(consumer_key = "MY_CONSUMER_KEY_HERE",
consumer_secret = "MY_CONSUMER_SECRET_HERE",
access_token="MY_ACCESS_TOKEN_HERE",
access_token_secret = "MY_ACCESS_SECRET_HERE")
filterStream("tweets.json", track = c("Obama", "Biden"), timeout = 120,
oauth = my_oauth)
#> Capturing tweets...
#> Connection to Twitter stream was closed after 120 seconds with up to 1146 tweets downloaded.
getUsers(screen_names="LSEnews", oauth = my_oauth) #not a function I see
#> Error in getUsers(screen_names = "LSEnews", oauth = my_oauth): could not find function "getUsers"
# List all functions in this package
ls("package:streamR")
#> [1] "createOAuthToken" "filterStream" "parseTweets"
#> [4] "readTweets" "sampleStream" "userStream"
filterStream(file.name="trump-tweets.json", track="trump", timeout=120, oauth=my_oauth)
#> Capturing tweets...
#> Connection to Twitter stream was closed after 120 seconds with up to 5187 tweets downloaded.
sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Catalina 10.15
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] streamR_0.4.5 ndjson_0.7.0 rjson_0.2.20 RCurl_1.95-4.12
#> [5] bitops_1.0-6
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.2 knitr_1.25 magrittr_1.5
#> [4] tidyselect_0.2.5 R6_2.4.0 rlang_0.4.0
#> [7] ROAuth_0.9.6 stringr_1.4.0 highr_0.8
#> [10] dplyr_0.8.3 tools_3.6.1 data.table_1.12.2
#> [13] xfun_0.9 htmltools_0.3.6 yaml_2.2.0
#> [16] digest_0.6.21 assertthat_0.2.1 tibble_2.1.3
#> [19] crayon_1.3.4 dtplyr_0.0.3 purrr_0.3.2
#> [22] glue_1.3.1 evaluate_0.14 rmarkdown_1.15
#> [25] stringi_1.4.3 compiler_3.6.1 pillar_1.4.2
#> [28] pkgconfig_2.0.3
由 reprex package (v0.3.0)
创建于 2019-10-01
我正在尝试使用 StreamR 和本指南从 Twitter 流式传输数据 https://github.com/pablobarbera/streamR
它最近工作正常,但现在我在尝试流式传输任何数据时遇到此错误;
library(ROAuth)
library(streamR)
my_oauth <- list(consumer_key = "...",
consumer_secret = "...",
access_token="...",
access_token_secret = "...")
getUsers(screen_names="LSEnews", oauth = my_oauth)
#Error in function (type, msg, asError = TRUE) :
#Unknown SSL protocol error in connection to api.twitter.com:443
When I try to stream tweets the connection closes after 0 second
filterStream(file.name="trump-tweets.json", track="trump", timeout=120, oauth=my_oauth)
#Capturing tweets...
#Connection to Twitter stream was closed after 0 seconds with up to 0 tweets #downloaded.
我已经在 Twitter 开发者网站上重新生成了我的客户密钥和访问令牌,并且还创建了一个新的应用程序。我还尝试更新 ROAuth 和 streamR 包。但是,当我尝试从 github 更新 streamR 时,出现此错误(我之前已经安装过该软件包,没有任何问题);
library(devtools)
#Loading required package: usethis
devtools::install_github("pablobarbera/streamR/streamR")
#Error in rethrow_call(c_processx_exec, command, c(command, args), stdin, :
# Incorrect number of arguments (16), expecting 14 for 'processx_exec'
这让我得到了这个答案,我可能需要更新 processx 包
https://github.com/r-lib/devtools/issues/2077
我已更新
install.packages("processx")
但这并没有解决问题,当我尝试从 Github 更新 StreamR 包时,仍然出现相同的错误。我还尝试通过 CRAN 安装 streamR-package;
install.packages("streamR")
install.packages("ROAuth")
但这并没有解决我关于流式推文的主要问题。
感谢任何帮助,谢谢!
我能够成功 运行 下面的代码(证明这确实是您的设置问题,并且 API 或包本身没有任何变化)。
几个注意事项:
- 我安装了 github 版的 streamR
- 请注意,我无法 运行 函数
getUsers
;我怀疑该功能来自 CRAN 版本 - 我已经包含了
sessionInfo()
的输出;也许如果您确保您拥有与我相同的包版本和 R 版本,您将能够 运行 成功或至少引导您朝着 的方向前进
library(streamR)
#> Loading required package: RCurl
#> Loading required package: bitops
#> Loading required package: rjson
#> Loading required package: ndjson
my_oauth <- list(consumer_key = "MY_CONSUMER_KEY_HERE",
consumer_secret = "MY_CONSUMER_SECRET_HERE",
access_token="MY_ACCESS_TOKEN_HERE",
access_token_secret = "MY_ACCESS_SECRET_HERE")
filterStream("tweets.json", track = c("Obama", "Biden"), timeout = 120,
oauth = my_oauth)
#> Capturing tweets...
#> Connection to Twitter stream was closed after 120 seconds with up to 1146 tweets downloaded.
getUsers(screen_names="LSEnews", oauth = my_oauth) #not a function I see
#> Error in getUsers(screen_names = "LSEnews", oauth = my_oauth): could not find function "getUsers"
# List all functions in this package
ls("package:streamR")
#> [1] "createOAuthToken" "filterStream" "parseTweets"
#> [4] "readTweets" "sampleStream" "userStream"
filterStream(file.name="trump-tweets.json", track="trump", timeout=120, oauth=my_oauth)
#> Capturing tweets...
#> Connection to Twitter stream was closed after 120 seconds with up to 5187 tweets downloaded.
sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Catalina 10.15
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] streamR_0.4.5 ndjson_0.7.0 rjson_0.2.20 RCurl_1.95-4.12
#> [5] bitops_1.0-6
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.2 knitr_1.25 magrittr_1.5
#> [4] tidyselect_0.2.5 R6_2.4.0 rlang_0.4.0
#> [7] ROAuth_0.9.6 stringr_1.4.0 highr_0.8
#> [10] dplyr_0.8.3 tools_3.6.1 data.table_1.12.2
#> [13] xfun_0.9 htmltools_0.3.6 yaml_2.2.0
#> [16] digest_0.6.21 assertthat_0.2.1 tibble_2.1.3
#> [19] crayon_1.3.4 dtplyr_0.0.3 purrr_0.3.2
#> [22] glue_1.3.1 evaluate_0.14 rmarkdown_1.15
#> [25] stringi_1.4.3 compiler_3.6.1 pillar_1.4.2
#> [28] pkgconfig_2.0.3
由 reprex package (v0.3.0)
创建于 2019-10-01