I am attempting to setup R's twitteR package to query tweets and am unfamiliar with the OAuth authorization process. Prior posts similar to this one have not indicated the necessity to go to a website and enter a number string (which is the message I recieve when attempting to authenticate). Has the process changed in the last year? Do I now need to enter my accessToken
and accessSecret
when authenticating?
Prior discussions on this subject are here:
ROAuth and twitteR, Mac OS X 10.7, R 2.15
TwitteR, ROAuth and Windows: register OK, but certificate verify failed
Here is the R code I am using and the command line responses:
> rm(list=ls())
> install.packages("twitteR")
> install.packages("ROAuth")
> library("twitteR")
> library('ROAuth')
> requestURL <- "https://api.twitter.com/oauth/request_token"
> accessURL = "http://api.twitter.com/oauth/access_token"
> authURL = "http://api.twitter.com/oauth/authorize"
> consumerKey = "......................" # Generated by Twitter API: httl://twitter.com/apps/new
> consumerSecret = "....................." # Generated by Twitter API
> Cred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=requestURL,
accessURL=accessURL,
authURL=authURL)
> 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=w09UEcpe4FUiomnX4ZHxnRbIJOqSntd4JY0shu0xo
When complete, record the PIN given to you and provide it here:
> registerTwitterOAuth(Cred)
Error: Forbidden
I have attempted to type the code provided but this yields the same error message. Anyone experience this problem?
System info: R version 3.1.0 (2014-04-10) -- "Spring Dance" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin13.1.0 (64-bit)
Update (Jun 3rd, 2014): Use GitHub Libraries to solve this problem
#install.packages(c("devtools", "rjson", "bit64")) # Intentional exclusion of ', "httr"'
# (2) Restart R
#install.packages("devtools")
library("devtools", lib.loc="/Users/wschram/Library/R/3.1/library")
devtools::install_github("hadley/httr")
library("httr", lib.loc="/Users/wschram/Library/R/3.1/library") # GitHub httr
install_github("twitteR", username="geoffjentry")
library(twitteR)
setup_twitter_oauth(API_Key, API_Secret, accessToken, accessSecret)
tweets <- searchTwitter('#beer', n=50)
head(tweets)