Created
December 13, 2013 12:45
-
-
Save mlist/7943747 to your computer and use it in GitHub Desktop.
how to use RCurl to access a grails controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
authenticate <- function(baseUrl="http://localhost:8080/GrailsApp/", user, password, verbose=F){ | |
require(RCurl) | |
loginUrl = paste(baseUrl, "login/auth", sep="") | |
authenticateUrl = paste(baseUrl, "j_spring_security_check", sep="") | |
cat(paste("trying to authenticate user", user)) | |
agent="Mozilla/5.0" | |
#Set RCurl pars | |
curl = getCurlHandle() | |
curlSetOpt(ssl.verifypeer=FALSE, timeout=60, cookiefile=tempfile(), cookiejar=tempfile(), useragent = agent, followlocation = TRUE, curl=curl, verbose=verbose) | |
#open login page | |
getURL(loginUrl, curl=curl) | |
#Post login form | |
postForm(authenticateUrl, .params= list(j_username=user, j_password=password), curl=curl, style="POST") | |
return(curl) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment