Results 1 to 3 of 3

Thread: [SOLVED]Sending SMS by using QNetworkAccessManager, QNetworkRequest and GET function

  1. #1
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question [SOLVED]Sending SMS by using QNetworkAccessManager, QNetworkRequest and GET function

    Hello All,

    I am trying to make a simple GUI which allows me to send a simple HTTPS URL with parameters under the form of https://herp.derp.com/sms/sendtxt.php?username=this&password=that&number=012 3456789&message=Lolhai&sender=MrCloud

    I've confirmed that using the above URL in Firefox sends my txt through, so it's my GUI that's failing.

    I've tried QHttp and I've tried QNetworkAccessManager, but to no avail. I feel like I'm missing something really trivial, so after googling relentlessly for two days without finding the answer, I feel like I need to ask a question specific to my project.

    This is the code I've been trying to get to work:

    Qt Code:
    1. void hcode::pbSendClicked(){
    2. QNetworkAccessManager *nwam = new QNetworkAccessManager();
    3.  
    4. QNetworkRequest request(QUrl("https://herp.derp.com/sms/sendtxt.php"));
    5.  
    6.  
    7. QByteArray data;
    8. QUrl params;
    9.  
    10. params.addQueryItem("username", ui->le1U->text());
    11. params.addQueryItem("password", ui->le2P->text());
    12. params.addQueryItem("mobilenumber", ui->le4N->text());
    13. params.addQueryItem("message", ui->teText->toPlainText());
    14. params.addQueryItem("sender", ui->le3S->text());
    15. params.addQueryItem("messagetype", "Text" );
    16. data=params.encodedQuery();
    17.  
    18. nwam->post(request,data);
    19. }
    To copy to clipboard, switch view to plain text mode 

    Everything the URL needs is queried from lineEdits and textEdits.

    What am I missing?

    Thanks in advance.


    Regards,
    Mr_Cloud
    Last edited by Mr_Cloud; 19th April 2013 at 06:43.

  2. #2
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo

    Default Re: Sending SMS by using QNetworkAccessManager, QNetworkRequest and POST function

    I'm a bit confused about your request.
    it looks like you don't need a POST method.

    have you try
    Qt Code:
    1. QNetworkAccessManager *nwam = new QNetworkAccessManager();
    2. QNetworkRequest request(QUrl("https://herp.derp.com/sms/sendtxt.php?username=this&password=that&number=0123456789&message=Lolhai&sender=MrCloud"));
    3.  
    4. nwam->get(request);
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to creation for this useful post:

    Mr_Cloud (19th April 2013)

  4. #3
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Sending SMS by using QNetworkAccessManager, QNetworkRequest and POST function

    Thank you creation! You're right, your solution worked. I also needed OpenSSL installed on my PC due to the HTTPS query. I'm working on linking the SSL DLLs now to eliminate that dependency. Thank you for your help.

    Edit: Following up on the SSL issue, installing OpenSSL and copypasta'ing libeay32.dll and ssleay32.dll in the exe directory solves the problem. I found that QtNetwork4.dll is now required to be included in the app directory as well now, alongside the aforementioned SSL dlls and QtCore4.dll, QtGui4.dll

    In conclusion: The app is working great.
    Last edited by Mr_Cloud; 19th April 2013 at 07:32.

Similar Threads

  1. QNetworkAccessManager post
    By januszmk in forum Newbie
    Replies: 2
    Last Post: 13th April 2012, 10:01
  2. QNetworkAccessManager.get(QNetworkRequest) not working.. :(
    By matthieunc in forum Qt Programming
    Replies: 4
    Last Post: 23rd July 2011, 14:18
  3. POST and QNetworkAccessManager
    By hakermania in forum Newbie
    Replies: 1
    Last Post: 13th February 2011, 01:05
  4. QNetworkAccessManager::post() never returns
    By danc81 in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2009, 10:13
  5. Replies: 5
    Last Post: 20th January 2009, 15:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.