0

I am working on an R script that will fetch posts from twitter. I've noticed that everytime I run below statements:

l_get <- GET( l_twitterQuery, config(httpheader = c("Authorization" = l_token)))

l_post   <- POST( url    = l_oAuthUrl
                , config( httpheader = c( "Authorization" = paste("Basic", l_encodCons)
                                        , "Content-Type"  = l_postContentType ))
                , body   = l_postBody
                , encode = l_encode
                );

Below warning message is displayed:

Warning message:
In curlOptions(..., .opts = .opts) :
  Duplicated curl options: proxyport, proxyuserpwd, proxy

I haven't found any good information on the web to solve this? Do I need to modify the httpheader only once in the set_config statement? Please find my script below:

Code:

###########################################################
#
# Libraries
#
###########################################################

library(httr)
library(jsonlite)
library(RCurl)
library(RJSONIO)

###########################################################
#
# Variables
#
###########################################################


# Proxy Variables for VPN
#l_proxyUrl    <- "XXXXXXXXXXXXXXX
#l_proxyPort   <- 80;

# Access Key , Tokens, POST, GETt variables
l_consKey     <- "YVY6KPUyNIhKLpz0Y66CJKssr";
l_consSecret  <- "noVJNzneZMuWq4uJSnX70Y20FAF2eu0gL42yhz9uq6xNEGlAiB";
l_cons        <- paste(l_consKey, l_consSecret, sep = ":");
l_encodCons   <- c()
l_token       <- c()
l_post        <- c()
l_get         <- c()

l_oAuthUrl    <- "https://api.twitter.com/oauth2/token";
l_postBody    <- "grant_type=client_credentials";
l_encode      <- "multipart";

l_postContentType <- "application/x-www-form-urlencoded;charset=UTF-8";

# Twitter Variables
l_twitterUrl      <- "https://api.twitter.com/1.1/search/tweets.json"
l_queryParams     <- "?q=%23Oracle&result_type=recent&count=100"
l_twitterQuery    <- c()

###########################################################
#
# Body
#
###########################################################

#Configure Proxy
#set_config( use_proxy( url  = l_proxyUrl, port = l_proxyPort ))

#Encode the consumer key and secret.
l_encodCons <- base64( txt = l_cons );

#Request
l_post   <- POST( url    = l_oAuthUrl
                , config( httpheader = c( "Authorization" = paste("Basic", l_encodCons)
                                        , "Content-Type"  = l_postContentType ))
                , body   = l_postBody
                , encode = l_encode
                );

l_token  <- paste("Bearer", content(l_post)$access_token)

i <- 0

while ( TRUE )
{

  l_twitterQuery <- paste(l_twitterUrl, l_queryParams, sep ="")
  l_get          <- GET( l_twitterQuery, config(httpheader = c("Authorization" = l_token)))
  l_results      <- content( l_get, as = "text")
  l_tweets       <- fromJSON(l_results)

  i <- i + 1    
  x <- names( l_tweets )[1]

  cat( sprintf( "System Time %s \t Iteration %s \t Names: %s \t Time Taken: %s \t Query: %s \n", Sys.time(), i, x, l_tweets$search_metadata$completed_in, l_twitterQuery ))

  l_queryParams  <- l_tweets$search_metadata$next_results

}

SessionInfo:

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Spanish_Mexico.1252  LC_CTYPE=Spanish_Mexico.1252    LC_MONETARY=Spanish_Mexico.1252 LC_NUMERIC=C                   
[5] LC_TIME=Spanish_Mexico.1252    

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

other attached packages:
[1] RJSONIO_1.3-0   jsonlite_0.9.14 httr_0.5        RCurl_1.95-4.4  bitops_1.0-6   

loaded via a namespace (and not attached):
[1] stringr_0.6.2 tools_3.1.0  
Andres Alvarado
  • 196
  • 1
  • 11
  • 1
    you do know there's [twitteR](http://cran.r-project.org/web/packages/twitteR/index.html) package, right? – hrbrmstr Jan 06 '15 at 21:47
  • Include the output of `sessionInfo()` so we know what versions of these packages you are running. Also, it's not particularly helpful to post your script if we can't run it thanks to missing keys. Try to post a `*minimal* reproducible example to make it easier for others to help you. – MrFlick Jan 06 '15 at 22:03
  • Hi @MrFlick I've added the information requested. – Andres Alvarado Jan 07 '15 at 14:53

0 Answers0