#include "tikonalogin.h"
#include "ui_tikonalogin.h"
tikonalogin
::tikonalogin(QWidget *parent
) : ui(new Ui::tikonalogin)
{
ui->setupUi(this);
acc = new QNetworkAccessManager(this);
connect(acc,SIGNAL(finished(QNetworkReply*)),this,SLOT(accFinish(QNetworkReply*)));
connect(acc,SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),this,SLOT(authReq(QNetworkReply*,QAuthenticator*)));
}
tikonalogin::~tikonalogin()
{
delete ui;
}
void tikonalogin::on_goButton_clicked()
{
QNetworkRequest request;
QUrl url
("https://www.whatever.in/login.do");
param.addQueryItem("type","2");
param.addQueryItem("username","abc");
param.addQueryItem("password","123");
data = param.encodedQuery();
// QString typ,username,password;
// typ="2";
// username="abc";
// password="123";
//request.setRawHeader("Authorization","Basic "+QByteArray(QString("%1:%2:%3").arg(typ).arg(username).arg(password).toAscii().toBase64()));
request.setUrl(url);
reply = acc->post(request,data);
//reply = acc->get(request);
connect(reply,SIGNAL(readyRead()),this,SLOT(readdata()));
}
void tikonalogin::accFinish(QNetworkReply *rep)
{
qDebug() << "Finished";
}
void tikonalogin::readdata(){
qDebug() << "Inside readdata()";
// qDebug() << s;
// ui->txDetails->setText(s);
}
void tikonalogin::authReq(QNetworkReply *, QAuthenticator *a){
qDebug() << "Authenticating";
a->setOption("type",2);
a->setUser("1103544735");
a->setPassword("Tech1234");
}
#include "tikonalogin.h"
#include "ui_tikonalogin.h"
tikonalogin::tikonalogin(QWidget *parent) :
QDialog(parent),
ui(new Ui::tikonalogin)
{
ui->setupUi(this);
acc = new QNetworkAccessManager(this);
connect(acc,SIGNAL(finished(QNetworkReply*)),this,SLOT(accFinish(QNetworkReply*)));
connect(acc,SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),this,SLOT(authReq(QNetworkReply*,QAuthenticator*)));
}
tikonalogin::~tikonalogin()
{
delete ui;
}
void tikonalogin::on_goButton_clicked()
{
QNetworkRequest request;
QUrl url ("https://www.whatever.in/login.do");
QByteArray data;
QUrl param;
param.addQueryItem("type","2");
param.addQueryItem("username","abc");
param.addQueryItem("password","123");
data = param.encodedQuery();
// QString typ,username,password;
// typ="2";
// username="abc";
// password="123";
//request.setRawHeader("Authorization","Basic "+QByteArray(QString("%1:%2:%3").arg(typ).arg(username).arg(password).toAscii().toBase64()));
request.setUrl(url);
reply = acc->post(request,data);
//reply = acc->get(request);
connect(reply,SIGNAL(readyRead()),this,SLOT(readdata()));
}
void tikonalogin::accFinish(QNetworkReply *rep)
{
qDebug() << "Finished";
}
void tikonalogin::readdata(){
qDebug() << "Inside readdata()";
QByteArray arr = reply->readAll();
QString s = arr.data();
// qDebug() << s;
// ui->txDetails->setText(s);
}
void tikonalogin::authReq(QNetworkReply *, QAuthenticator *a){
qDebug() << "Authenticating";
a->setOption("type",2);
a->setUser("1103544735");
a->setPassword("Tech1234");
}
To copy to clipboard, switch view to plain text mode
Bookmarks