【发布时间】:2013-06-04 00:10:36
【问题描述】:
我正在尝试使用 R 向 Twitter 进行身份验证,但我无法获得 PIN。
我的代码如下:
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
reqURL <- "http://api.twitter.com/oauth/request_token"
accessURL <- "http://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- "foo"
consumerSecret <- "bar"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL
)
twitCred$handshake(cainfo="cacert.pem", ssl.verifypeer=FALSE)
但是,当我取回授权 URL 并输入它时,我仍然没有得到 PIN:我只有一个按钮来授权应用程序,然后我最终回到了我之前的返回 URL指定。
这似乎与这个问题非常相似 Where does twitteR PIN code appear during R oauth authentication? 但那里的补救措施(确保请求、访问和身份验证 URL 都是 http 而不是 https)对我不起作用。
我在 Windows 7 上运行 R 3.0.0,ROAuth 是 0.9.2,twitteR 1.1.0 - 其中任何一个都表明为什么会出现这个问题?
【问题讨论】:
-
也许您需要更新您的 cacert.pem 文件。看看here 看看这是否有帮助。这个问题已经发布了很多次,exact 相同的代码。当您克服了这个问题后,您自己确切地回答您所做的会很有帮助,因为目前这个问题每天都会被问到一次。
-
谢谢西蒙。当我按照您的建议尝试刷新 cacert.pem 时,我得到“C:\Users\V-JFOR~1\AppData\Local\Temp\Rtmp4Y79aI/cacert.pem' has status 309”。我认为那是因为 curl 在我的机器上无法正常工作。最新的 cacert.pem 应该在哪里?在 R 工作目录中?
标签: r twitter-oauth roauth