警告消息:在curlOptions中:重复的卷曲选项

时间:2015-01-06 20:59:36

标签: r rcurl httr rjsonio jsonlite

我正在制作一个可以从twitter上获取帖子的R脚本。我注意到每次运行以下语句时都会发现:

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

显示以下警告信息:

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

我在网上找不到任何好的信息来解决这个问题?我是否需要在set_config语句中仅修改一次httpheader?请在下面找到我的脚本:

代码:

###########################################################
#
# 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  

0 个答案:

没有答案