void FenPrincipale::takeCookies()
{
postData.addQueryItem("username","user101");
postData.addQueryItem("password",var2_Edit->text());
postData.addQueryItem("warn", "true");
postData.addQueryItem("lt", lt);
postData.addQueryItem("_eventId", "submit");
postData.addQueryItem("submit", "SE CONNECTER");
// On crée une requête
QNetworkRequest requete
(QUrl(urlEdit1
->text
()));
requete.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
r = m->post(requete, postData.encodedQuery());
// Gestion des erreurs
connect(r, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(messageErreur(QNetworkReply::NetworkError)));
// Gestion de fin de téléchargement
connect(r, SIGNAL(finished()), this, SLOT(takeLink()));
}
// The second slot for the reply
void FenPrincipale::takeLink()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(sender());
QNetworkAccessManager *m = reply->manager();
m->setCookieJar(new CookieJar(this));
qDebug() << reply->readAll();
}
void FenPrincipale::takeCookies()
{
QUrl postData;
postData.addQueryItem("username","user101");
postData.addQueryItem("password",var2_Edit->text());
postData.addQueryItem("warn", "true");
postData.addQueryItem("lt", lt);
postData.addQueryItem("_eventId", "submit");
postData.addQueryItem("submit", "SE CONNECTER");
// On crée une requête
QNetworkRequest requete(QUrl(urlEdit1->text()));
requete.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
r = m->post(requete, postData.encodedQuery());
// Gestion des erreurs
connect(r, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(messageErreur(QNetworkReply::NetworkError)));
// Gestion de fin de téléchargement
connect(r, SIGNAL(finished()), this, SLOT(takeLink()));
}
// The second slot for the reply
void FenPrincipale::takeLink()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(sender());
QNetworkAccessManager *m = reply->manager();
m->setCookieJar(new CookieJar(this));
qDebug() << reply->readAll();
}
To copy to clipboard, switch view to plain text mode
Bookmarks