0

Is there any way to assign variable to a http GET request form using rcurl?

eg:

getURL("https://testme.com/www//LoginService/login?login=xyz&password=<variable>")

I need to pass the value of password as a variable.

Regards ...

MujtabaFR
  • 5,956
  • 6
  • 40
  • 66
san71
  • 47
  • 7
  • Just for future contributions: 1. make sure you include desired output (even if in pseudo code or whatnot) to make your intent clear as Brita filtered water. 2. always check your questions against: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for ideal formatting. – npjc May 28 '14 at 03:08

2 Answers2

3

What about using paste0?

library("RCurl")
mypw <- "may1989"
basereq <- "https://testme.com/www//LoginService/login?login=xyz&password="
fullreq <- paste0( basereq, mypw, "/" )

So the full request looks like:

fullreq
## [1] "https://testme.com/www//LoginService/login?login=xyz&password=may1989/"

which you can curl in:

getURL(fullreq)
Thomas
  • 43,637
  • 12
  • 109
  • 140
npjc
  • 4,134
  • 1
  • 22
  • 34
3

Try httr:

library(httr)

GET("https://testme.com/www/LoginService/login", 
  query = list(login = "xyz", password = variable)
)

httr will automatically escape variable as needed.

hadley
  • 102,019
  • 32
  • 183
  • 245