How to use wxCURL to login a web and get other pages?  [SOLVED]

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
kipade
Earned some good credits
Earned some good credits
Posts: 116
Joined: Fri Nov 11, 2011 2:45 am
Location: China

How to use wxCURL to login a web and get other pages?

Postby kipade » Tue Oct 16, 2012 6:18 am

There is a website, its need to login to get other pages.
I use wxCurlHttp to post login data to the login page(because its login page use POST http method). However, after I login successfully, I redirect to other pages, I still got the error page which told me that I should login first. No matter if I use two different wxCurlHttp object or not.
There is a WINET based http wrapper named W3Client at codeproject.com:http://www.codeproject.com/Articles/6939/WWW-HTTP-HTTPS-FTP-Client-using-WININET, if I build a W3Client to get some pages after post data to login page, all things got ok. Because this wrapper is plat-form depedent and non-wx based, its just to be a example.
How to reach this goal use wxCURL? or other method?
Slackware GNU/Linux
wxWidgets-3.0.3

utelle
Moderator
Moderator
Posts: 767
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: How to use wxCURL to login a web and get other pages?  [SOLVED]

Postby utelle » Tue Oct 16, 2012 4:16 pm

kipade wrote:There is a website, its need to login to get other pages.
I use wxCurlHttp to post login data to the login page(because its login page use POST http method). However, after I login successfully, I redirect to other pages, I still got the error page which told me that I should login first. No matter if I use two different wxCurlHttp object or not. [...] How to reach this goal use wxCURL? or other method?

How to handle this problem depends on which kind of authentication is used. In case of basic authentication you have to pass user ID and password with each request. If the login process results in session cookies you have to pass these on each request.

That is, first you have to check how the website you try to access handles authentication.

Regards,

Ulrich

kipade
Earned some good credits
Earned some good credits
Posts: 116
Joined: Fri Nov 11, 2011 2:45 am
Location: China

Re: How to use wxCURL to login a web and get other pages?

Postby kipade » Fri Oct 19, 2012 8:43 am

Thanks for your replay. I had dumped all the http get and post raw text data, and then resolved the problem:
just call UseCookies(true);

btw, I found the SetURL function should be extended or add some other functions to navigate with a website freely, because SetURL use relative url always.
Slackware GNU/Linux
wxWidgets-3.0.3


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 2 guests