PDA

View Full Version : [SOLVED]Sending SMS by using QNetworkAccessManager, QNetworkRequest and GET function



Mr_Cloud
19th April 2013, 03:27
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=0123456789&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:


void hcode::pbSendClicked(){
QNetworkAccessManager *nwam = new QNetworkAccessManager();

QNetworkRequest request(QUrl("https://herp.derp.com/sms/sendtxt.php"));


QByteArray data;
QUrl params;

params.addQueryItem("username", ui->le1U->text());
params.addQueryItem("password", ui->le2P->text());
params.addQueryItem("mobilenumber", ui->le4N->text());
params.addQueryItem("message", ui->teText->toPlainText());
params.addQueryItem("sender", ui->le3S->text());
params.addQueryItem("messagetype", "Text" );
data=params.encodedQuery();

nwam->post(request,data);
}

Everything the URL needs is queried from lineEdits and textEdits.

What am I missing?

Thanks in advance.


Regards,
Mr_Cloud

creation
19th April 2013, 05:56
I'm a bit confused about your request.
it looks like you don't need a POST method.

have you try


QNetworkAccessManager *nwam = new QNetworkAccessManager();
QNetworkRequest request(QUrl("https://herp.derp.com/sms/sendtxt.php?username=this&password=that&number=0123456789&message=Lolhai&sender=MrCloud"));

nwam->get(request);

Mr_Cloud
19th April 2013, 06:42
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.