Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

r - twitteR throws Forbidden error after entering twitter API PIN

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.

The Code:

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)
}

The Response:

TwitterOAuth() To enable the connection, please direct your web browser to: http://api.twitter.com/oauth/authorize?oauth_token=X0AwET4FXBC7YRIWWN3iF61WFNE1DjxbfibqtfFjgcc
When complete, record the PIN given to you and provide it here: 1998913
Error: Forbidden

My sessionInfo()

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

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

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Change your access URL from http to https.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...