I want my app to login to a site, but first it needs to go to the mainpage and get a session id.
QNetworkAccessManager *manager = new QNetworkAccessManager;
QNetworkRequest request;
request.setUrl(furl);
//SIGNAL SLOT
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(Getreply(QNetworkReply*)));
manager->get(request);
QNetworkAccessManager *manager = new QNetworkAccessManager;
QNetworkRequest request;
request.setUrl(furl);
//SIGNAL SLOT
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(Getreply(QNetworkReply*)));
manager->get(request);
To copy to clipboard, switch view to plain text mode
And then I get the session ID at the Getreply slot. Next, I need to post data, username and password.
void Getreply()
{
//Edit parameters, url etc....
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(Getlogin(QNetworkReply*)));
manager->post(request)
}
void Getreply()
{
//Edit parameters, url etc....
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(Getlogin(QNetworkReply*)));
manager->post(request)
}
To copy to clipboard, switch view to plain text mode
Getlogin will have codes like check if login success and so on..
This first problem is, when the manager signal emits finished(QNetworkReply*) in Getreply(), I believe not only Getlogin will run, but also Getreply, because both are now connected signal slots. How can I turn the first "connect" off, or what other solution can I have.
Second, I created all the variables on the first function, but then I need to edit stuff like post data at the second function, Getreply, i'm forced to make them global. Any other ways?
Thx.
Bookmarks