[R] RCurl: authentication when posting forms

Duncan Temple Lang duncan at wald.ucdavis.edu
Thu Aug 28 17:33:55 CEST 2008



Hi Valerie

Valerie Obenchain wrote:
> Hi,
> 
> Has anyone successfully used RCurl for posting data to a 
> password-protected site? 

Yes. I just set up a sample form to test with and the following
all work


# Perl script (and HTML form for testing in the browser) taken from
#   http://www.elated.com/articles/form-validation-with-perl-and-cgi/


# Provide the login & password directly
postForm("http://www.omegahat.org/RCurl/testPassword/form_validation.cgi",
            your_name = "Duncan",
            your_age = "35-55",
            your_sex = "m",
            submit = "submit",
            .opts = list(userpwd = "bob:welcome"))

# Get the login & password in ~/.netrc
postForm("http://www.omegahat.org/RCurl/testPassword/form_validation.cgi",
            your_name = "Duncan",
            your_age = "35-55",
            your_sex = "m",
            submit = "submit",
           .opts = list(netrc = TRUE))

# Get the login & password from a different netrc file

postForm("http://www.omegahat.org/RCurl/testPassword/form_validation.cgi",
            your_name = "Duncan",
            your_age = "35-55",
            your_sex = "m",
            submit = "submit",
            .opts = list(netrc = TRUE,
                         netrc.file = 
"/Users/duncan/Projects/org/omegahat/R/RCurl/inst/examples/omg.netrc"))


So let me know what problems you are having and more details
about the OS, version of libcurl, and a sample URL to which
to post, etc.

   D.

 >I
> have tired using option netrc=1 with both postForm and curlPerform (with 
> postfields option) but can't authenticate.
> I would happily provide more details if some one has had some experience 
> with this.
> 
> Thanks very much.
> Valerie
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list