RajabNatshah
1st March 2010, 14:31
Hi All
I'm working on SMS Getaway system. which works.
I'm using the SMS Getaway system using Http
I did make it work on C# like this code..
// Get Balance from Mobily.ws API Balance ..
private string GetBalance()
{
HttpWebRequest req =(HttpWebRequest)WebRequest.Create("http://www.mobily.ws/api/balance.php?mobile="+MobilyUserName+"&password="+MobilyPassword);
WebResponse resp = req.GetResponse();
Stream s = resp.GetResponseStream();
StreamReader sr= new StreamReader(s, Encoding.ASCII);
String doc = sr.ReadToEnd();
return doc;
}
but using Qt is not working..
QString mainDialog::getBalance()
{
http = new QHttp(this);
connect(http, SIGNAL(readyRead(const QHttpResponseHeader &)), this, SLOT(readGetBalanceData(const QHttpResponseHeader &)));
QString getBalancelink = "http://www.mobily.ws/api/balance.php?mobile=" + MobilyUserName + "&password=" + MobilyPassword ;
QUrl url(getBalancelink);
QByteArray byteArray;
http->setHost(url.host());
QHttpRequestHeader header("POST" ,"/api/balance.php?mobile=" + MobilyUserName + "&password=" + MobilyPassword);
header.setValue("Host", "http://www.mobily.ws");
header.setValue("Content-Type", "application/x-www-form-urlencoded");
http->request(header,byteArray);
http->close();
QString str = QString(byteArray);
return str ;
}
And sending message in C# is working as in this code
// This Method let you send Message
private void sendMessage()
{
HttpWebRequest req =(HttpWebRequest)WebRequest.Create("http://www.mobily.ws/api/msgSend.php");
String s1 = "mobile=" + MobilyUserName + "&password=" + MobilyPassword + "&numbers=" + textBoxNumbers.Text + "&sender=" + textBoxSender.Text + "&msg=" + convertToUnicode(textBoxMessage.Text) + "&applicationType=24";
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
Byte[] byteArray = Encoding.UTF8.GetBytes(s1);
req.ContentLength = byteArray.Length;
Stream dataStream= req.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse resp= req.GetResponse();
Stream s = resp.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.ASCII);
String doc = sr.ReadToEnd();
showResult(doc);
}
But for QT is not..
void mainDialog::sendMessage()
{
http = new QHttp(this);
connect(http, SIGNAL(done(bool)), this, SLOT(showResult()));
http->setHost("http://www.mobily.ws");
QString s1 = "mobile=" + MobilyUserName + "&password=" + MobilyPassword + "&numbers=" + plainTextEditNumbers->toPlainText() + "&sender=" + lineEditSender->text() + "&msg=" + plainTextEditMessage->toPlainText()+ "&applicationType=24";
http->get(s1);
}
I do not know if I'm messing any Objects in QT .... I'm using the SMS Getaway system using Http
Best Regards :)
I'm working on SMS Getaway system. which works.
I'm using the SMS Getaway system using Http
I did make it work on C# like this code..
// Get Balance from Mobily.ws API Balance ..
private string GetBalance()
{
HttpWebRequest req =(HttpWebRequest)WebRequest.Create("http://www.mobily.ws/api/balance.php?mobile="+MobilyUserName+"&password="+MobilyPassword);
WebResponse resp = req.GetResponse();
Stream s = resp.GetResponseStream();
StreamReader sr= new StreamReader(s, Encoding.ASCII);
String doc = sr.ReadToEnd();
return doc;
}
but using Qt is not working..
QString mainDialog::getBalance()
{
http = new QHttp(this);
connect(http, SIGNAL(readyRead(const QHttpResponseHeader &)), this, SLOT(readGetBalanceData(const QHttpResponseHeader &)));
QString getBalancelink = "http://www.mobily.ws/api/balance.php?mobile=" + MobilyUserName + "&password=" + MobilyPassword ;
QUrl url(getBalancelink);
QByteArray byteArray;
http->setHost(url.host());
QHttpRequestHeader header("POST" ,"/api/balance.php?mobile=" + MobilyUserName + "&password=" + MobilyPassword);
header.setValue("Host", "http://www.mobily.ws");
header.setValue("Content-Type", "application/x-www-form-urlencoded");
http->request(header,byteArray);
http->close();
QString str = QString(byteArray);
return str ;
}
And sending message in C# is working as in this code
// This Method let you send Message
private void sendMessage()
{
HttpWebRequest req =(HttpWebRequest)WebRequest.Create("http://www.mobily.ws/api/msgSend.php");
String s1 = "mobile=" + MobilyUserName + "&password=" + MobilyPassword + "&numbers=" + textBoxNumbers.Text + "&sender=" + textBoxSender.Text + "&msg=" + convertToUnicode(textBoxMessage.Text) + "&applicationType=24";
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
Byte[] byteArray = Encoding.UTF8.GetBytes(s1);
req.ContentLength = byteArray.Length;
Stream dataStream= req.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse resp= req.GetResponse();
Stream s = resp.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.ASCII);
String doc = sr.ReadToEnd();
showResult(doc);
}
But for QT is not..
void mainDialog::sendMessage()
{
http = new QHttp(this);
connect(http, SIGNAL(done(bool)), this, SLOT(showResult()));
http->setHost("http://www.mobily.ws");
QString s1 = "mobile=" + MobilyUserName + "&password=" + MobilyPassword + "&numbers=" + plainTextEditNumbers->toPlainText() + "&sender=" + lineEditSender->text() + "&msg=" + plainTextEditMessage->toPlainText()+ "&applicationType=24";
http->get(s1);
}
I do not know if I'm messing any Objects in QT .... I'm using the SMS Getaway system using Http
Best Regards :)