这个问题实际上回答了所有与 twitteR ROAuth 问题相关的问题:
TwitteR、ROAuth 和 Windows:注册成功,但证书验证失败
TwitteR 和 ROAuth 之前都在我的电脑上完美运行。但是代码块不再生成 PIN 选项。它弹出以下内容:
twitCred$handshake(cainfo="cacert.pem")
Error: Unauthorized
以前twitCred$handshake(cainfo="cacert.pem")指向:
To enable the connection, please direct your web browser to:
https://api.twitter.com/oauth/authorize?oauth_token=SevxcpCh9riO5PPrI8U8____
When complete, record the PIN given to you
我在 spark rstudio 服务器中尝试了我的代码。然后代码完美运行(生成输入 PIN 的选项,目前在我的电脑中没有生成)。代码是:
require(twitteR)
require(ROAuth)
requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
consumerKey <- "______________"
consumerSecret <- "___________________"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret, requestURL=requestURL, accessURL=accessURL,
authURL=authURL)
setwd("/home/__")
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
twitCred$handshake(cainfo="cacert.pem")
To enable the connection, please direct your web browser to:
https://api.twitter.com/oauth/authorize?oauth_token=SevxcpCh9riO5PPrI8U8____
When complete, record the PIN given to you
任何帮助表示赞赏。