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

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

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

Post by kipade »

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/693 ... ng-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 x86_64
wxWidgets-3.3.0
utelle
Moderator
Moderator
Posts: 1125
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?

Post by utelle »

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: 126
Joined: Fri Nov 11, 2011 2:45 am
Location: China

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

Post by kipade »

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 x86_64
wxWidgets-3.3.0
Post Reply