cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Question on using cURL in java...

From: s.e.t.i. <setigamer_at_gmail.com>
Date: Wed, 23 Feb 2005 09:23:44 -0800

Javacurl does not have support for posting
multipart/formdata(OPT_POST).So you have to use
cg.setopt(CURL.OPT_HTTPPOST, 1);. You should be able to post your
fields as you showed in your code
"post1=data1&post2=data2&post3=data3". Also, make sure your
"cookieString" contains the name of the cookie file you want to use.

You should be set to go, good luck.

On Tue, 22 Feb 2005 14:35:01 -0800, Qian Su <qsu_at_cj.com> wrote:
>
>
>
> Hi,
>
>
>
> I'm new to cURL in general, and I'm not good with C. I'm trying to use
> javacurl to post simple data (a secure login page) over https but failed.
> From the verbose printout of cURL, it seems that there is a certificate
> verification failure and the error page returned from the server suggests
> the user to accept cookies. I'm assuming that I'm not setting the cookies
> configuration correctly, though I thought that cURL manages cookies and
> sessions internally. Below is my code snippet:
>
>
>
> CurlGlue cg = new CurlGlue();
>
> cg.setopt(CURL.OPT_WRITEFUNCTION, cw);
>
>
>
> cg.setopt(CURL.OPT_VERBOSE, 3);
>
> cg.setopt(CURL.OPT_FOLLOWLOCATION, 1);
>
> cg.setopt(CURL.OPT_SSL_VERIFYPEER, 0);
>
> cg.setopt(CURL.OPT_SSL_VERIFYHOST, 0);
>
> cg.setopt(CURL.OPT_SSLCERTTYPE, "PEM");
>
> cg.setopt(CURL.OPT_SSLVERSION, 3);
>
>
>
> int result = cg.setopt(CURL.OPT_URL,
> "https://www.mail.yahoo.com/");
>
>
>
> // post method
>
> cg.setopt(CURL.OPT_POST, 1);
>
>
>
> // IS THIS THE RIGHT WAY TO SET SIMPLE POST DATA?
>
> cg.setopt(CURL.OPT_POSTFIELDS, "some
> post data");
>
>
>
> // IS THIS THE RIGHT WAY TO SET COOKIE?
>
> if(cookieString != null)
>
> cg.setopt(OPT_COOKIE, cookieString);
>
>
>
> cg.perform();
>
>
>
> I would really appreciate some guidance here.
>
>
>
> Thanks!
>
> Qian
>
>
>
>
>
>
>
>

-- 
Cheers... s.e.t.i.
Received on 2005-02-23