本文介绍了twitteR 在输入 twitter API PIN 后抛出禁止错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 R 和 twitteR 包分析一些推文.握手和注册码似乎工作正常,我从 R 获得授权链接.但是,当我输入从 https:/获得的 PIN 时/api.twitter.com/oauth/authorize 我收到禁止错误".任何帮助表示赞赏.

I am trying to analyze some tweets using R and twitteR package. The handshake and registration code seems to work properly and I get the authorization link from R. However, when I enter the PIN obtained from https://api.twitter.com/oauth/authorize I get a "Forbidden Error." Any help is appreciated.

代码:

TwitterOAuth<-function(){
  reqURL <- "https://api.twitter.com/oauth/request_token"
  accessURL <- "http://api.twitter.com/oauth/access_token"
  authURL <- "http://api.twitter.com/oauth/authorize"
  consumerKey <- "xxxxxxxxxxxxxxxx"
  consumerSecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  twitCred <- OAuthFactory$new(consumerKey=consumerKey,
                             consumerSecret=consumerSecret,
                             requestURL=reqURL,
                             accessURL=accessURL,
                             authURL=authURL)
  options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package =  "RCurl")))
  twitCred$handshake()
  registerTwitterOAuth(twitCred)
}

回应:

TwitterOAuth()要启用连接,请将您的网络浏览器定向到:http://api.twitter.com/oauth/authorize?oauth_token=X0AwET4FXBC7Fjwnf>ccfbc7Fjwnf
完成后,记录给您的 PIN 并在此处提供:1998913
错误:禁止

我的 sessionInfo()

My sessionInfo()

R 版本 3.0.2 (2013-09-25)平台:x86_64-w64-mingw32/x64(64位)

R version 3.0.2 (2013-09-25)Platform: x86_64-w64-mingw32/x64 (64-bit)

地区:[1] LC_COLLATE=Turkish_Turkey.1254 LC_CTYPE=Turkish_Turkey.1254 LC_MONETARY=Turkish_Turkey.1254[4] LC_NUMERIC=C LC_TIME=Turkish_Turkey.1254

locale:[1] LC_COLLATE=Turkish_Turkey.1254 LC_CTYPE=Turkish_Turkey.1254 LC_MONETARY=Turkish_Turkey.1254[4] LC_NUMERIC=C LC_TIME=Turkish_Turkey.1254

附加基础包:[1] stats 图形 grDevices utils datasets 方法基础

attached base packages:[1] stats graphics grDevices utils datasets methods base

其他附加包:[1] twitteR_1.1.7 rjson_0.2.13 ROAuth_0.9.3digest_0.6.4 RCurl_1.95-4.1 bitops_1.0-6

other attached packages:[1] twitteR_1.1.7 rjson_0.2.13 ROAuth_0.9.3 digest_0.6.4 RCurl_1.95-4.1 bitops_1.0-6

通过命名空间加载(且未附加):[1] 工具_3.0.2

loaded via a namespace (and not attached):[1] tools_3.0.2

推荐答案

将您的访问 URL 从 http 更改为 https.

Change your access URL from http to https.

这篇关于twitteR 在输入 twitter API PIN 后抛出禁止错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 17:16