PDA

View Full Version : Qhttp



incapacitant
6th May 2006, 17:37
I modified slightly the example network/qhttp with the following url :


QLineEdit("http://api.smsbox.fr/index.php?login=ahcoeur&pass=aaaaaa&action=credit");


which is a valid url that replies "CREDIT 362"

however the server replies :
"ERROR 01" missing parameters

can you help ?

madcat
7th May 2006, 15:55
Hi,
I never played with QUrl, but it looks like it does not accept url with GET items (like ?user=something&pass=xxx) in the constructor. Maybe you should just do a


QUrl url;
url->setEncodedQuery(urlLineEdit->text());

but I'm not sure that encodedQuery is the right function
As a last resort, you would have to use the query items related functions of QUrl...

incapacitant
7th May 2006, 18:30
So I tried :



QByteArray qba;
qba.append("http://api.smsbox.fr/index.php?login=xx&pass=xx&action=credit");
QUrl url;
url.setEncodedUrl(qba);


Result is the same : missing parameters, it does not like this kind of url fr some reason.
setEncodedQuery causes an unknown error from the QT4 sample and does not reply at all.

jpn
8th May 2006, 06:56
All you need to change is:


httpGetId = http->get(url.path(), file);

to:


httpGetId = http->get(url.toString(), file);


QUrl::path() returns only the path part of the URL so you end up sending the GET request without appropriate query parameters.

incapacitant
8th May 2006, 21:08
many many thanks