【问题标题】:Cannot get PIN using ROauth无法使用 ROauth 获取 PIN
【发布时间】:2013-03-10 00:03:24
【问题描述】:

我想将 R 连接到 Twitter。 我已按照此处设置的步骤进行操作: http://cran.r-project.org/web/packages/twitteR/vignettes/twitteR.pdf

我的代码如下:

library(ROAuth)
cred <- OAuthFactory$new(consumerKey="xyz",
consumerSecret=xyz",
requestURL="https://api.twitter.com/oauth/request_token",
accessURL="https://api.twitter.com/oauth/authorize",
authURL="https://api.twitter.com/oauth/access_token")
cred$handshake(ssl.verifypeer = FALSE)

当我得到推特链接时: https://api.twitter.com/oauth/access_token?oauth_token=YZZOYJ1liH1TDEY8G6Eb3YmgAWQlgGiEfAzI1ADwZ4

并将其加载到我的浏览器中,它会返回一个空白页面,其中没有关于 PIN 的信息。谁能告诉我为什么这个链接是空白的

【问题讨论】:

    标签: r oauth twitter rcurl


    【解决方案1】:

    因为您访问了错误的 URL 来进行授权。交换您的 authaccess 网址!

    accessURL="https://api.twitter.com/oauth/access_token",
    authURL="https://api.twitter.com/oauth/authorize")
    
    #You should get...
    Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") )   
    To enable the connection, please direct your web browser to: 
    http://api.twitter.com/oauth/authorize?oauth_token=someaccessstokenvalue
    When complete, record the PIN given to you and provide it here: 
    
    #Final step to register connections
    registerTwitterOAuth(Cred)
    

    【讨论】:

    • SimonO101,感谢您的帮助。我觉得真的很愚蠢,但我正在努力掌握这个 R 包。我能问一下您为什么更改以下代码吗?有什么好处Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") )
    • 没问题! cainfo 位告诉系统在哪里可以找到RCurl 提供的特定cacert 文件。 cacert 文件包含公共证书颁发机构的证书,您的系统使用这些证书来验证称自己为 Twitter 的服务器确实是它所说的那个人。有时,与 Curl 一起使用的默认文件可能已过期,系统无法验证它从服务器接收到的证书。 (这往往在 Windows 系统上发生更多)。
    • 别觉得自己很蠢!我们都应该每天努力学习更多。
    • 如果这回答了您的问题,请按我的答案旁边的绿色勾号,以便可以从未回答的问题堆栈中删除此问题。谢谢!
    • NP。向上和向上。欢迎来到 SO。 :-)
    猜你喜欢
    • 2019-09-10
    • 2013-09-02
    • 1970-01-01
    • 2013-08-12
    • 1970-01-01
    • 2013-12-08
    • 2012-11-24
    • 2022-11-16
    • 2015-06-25
    相关资源
    最近更新 更多