Hi!
I am trying to write program which shows amount of money on my ISP account. The idea is to pass a POST request to index.php and receive generated html page, but there is ssl installed and that is a problem. When I am trying to pass my login and password to index.php through my program, as an output i receive main page as if login or password is incorrect.
Qt Code:
  1. #ifndef STAT_H
  2. #define STAT_H
  3. #include <QtNetwork>
  4. #include <QtGui>
  5.  
  6. #include "ui_stat.h"
  7.  
  8. class Stat : public QDialog, public Ui::dialog
  9. {
  10. Q_OBJECT
  11. public:
  12. Stat (const QString &host)
  13. {
  14. setupUi ( this );
  15. connect (&http, SIGNAL( requestFinished(int,bool)),this,SLOT(end()));
  16. connect ( statButton, SIGNAL ( clicked ( ) ), this, SLOT ( send ( ) ) );
  17. http.setHost ( host, QHttp::ConnectionModeHttps );
  18. }
  19.  
  20.  
  21. void sendData (const QString &input1, const QString &input2 )
  22. {
  23. data.append ( "FindUserName=");
  24. data.append (input1);
  25. data.append ( "&FindUserPass=");
  26. data.append ( input2 );
  27. outFile .setFileName ( "out.html" );
  28. outFile.open (QIODevice:: WriteOnly | QIODevice::Truncate);
  29. QSslSocket *socket = new QSslSocket;
  30. socket->connectToHostEncrypted ( "stat.ultranet.ru", 443 );
  31. if ( socket->waitForEncrypted ( 5000) )
  32. {
  33. http.setSocket ( socket );
  34. QHttpRequestHeader header ( "POST", "/index.php" );
  35. header.setValue ( "Content-Type", "application/x-www-form-urlencoded" );
  36. header.setValue ( "Host", "stat.ultranet.ru" );
  37. http.request ( header, data, &outFile );
  38. }
  39. }
  40.  
  41. public slots:
  42. void end( )
  43. {
  44. outFile.close ( );
  45. emit done();
  46. }
  47.  
  48. void send ( )
  49. {
  50. sendData ( loginLineEdit ->text( ), passwLineEdit ->text( ) ) ;
  51. }
  52.  
  53.  
  54.  
  55. signals:
  56. void done( );
  57. private:
  58. QFile outFile;
  59. QHttp http;
  60. QByteArray data;
  61. };
  62. #endif
To copy to clipboard, switch view to plain text mode