PDA

View Full Version : [QUrl] Auto-Login



debmag
22nd October 2008, 23:02
Hi,

I've a small problem.

How did use this class for complete my login webpage ?

A part of my code :


QApplication app(argc, argv);

QByteArray content("login=root&passwd=root");

QHttpRequestHeader header("POST", "login.yahoo.com/config/login?");
header.setValue("Host", "login.yahoo.com/config/login?");
header.setContentType("application/x-www-form-urlencoded"); // important
header.setContentLength(content.length());

// request
QFile file("result.html");

QHttp http("login.yahoo.com/config/login?");
http.request(header, content, &file);
QUrl url2(http->text());



app.connect(&http, SIGNAL(done(bool)), &app, SLOT(quit()));


I'm test with this code, but this open a browser without complete value.




QUrl url("https://login.yahoo.com/config/login?");

url.setUserName("login=root&passwd=root");

QDesktopServices::openUrl(url);





Where the mistake please ?

Thx

wysota
22nd October 2008, 23:34
I see at least two problems but I think the main problem is that you don't know which classes to use. If you want to make a http request (which I think you do) use QHttp or better yet QNetworkAccessManager. Another problem is the format of data you want to send, but I can't help you here. It's best to see how the original application (browser) does that and mimic it.

debmag
23rd October 2008, 07:41
Tanks for your help...

If i want is much easy :

view in my default browser (qdesktopservices) the webpage "login.yahoo.com/config/login?". After that, the form login and password complete by the request, and submit all for open my yahoo page.


QNetworkAccessManager doesn't easy to implemente, have you any example in my problem ?

Thx