从应用程序连接到php脚本并检索数据


connect from an app to a php-script and retrieve the data?

我正在Qt/QML中为Android编写一个需要与MySQL数据库同步的应用程序。

我将使用php脚本进行服务器和移动设备之间的通信。

但我不明白的是如何连接到php Web服务并从中检索数据。

如何从应用程序连接到php脚本,并从php脚本查询到sql server的查询中检索数据?

我不需要一个完整的解释,只需要一点方向。我不是要求被人用勺子舀。

你应该如何与脚本互动?

你需要通过http发送某种字符串吗?是否可以通过http在服务器之间发送字符串?如果是,如何?你在URL或类似的东西中输入数据吗?如果是这样,php脚本是否应该接收请求,它是否可以解析url?

关于这种交互如何工作的一个小描述将被称为

void Downloader::doDownload() 
{ 
    manager = new QNetworkAccessManager(this); 
    connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); 
    manager->get(QNetworkRequest(QUrl("http://bogotobogo.com"))); 
}
void Downloader::replyFinished (QNetworkReply *reply) 
{ 
    if(reply->error()) { qDebug() << "ERROR!"; 
        qDebug() << reply->errorString(); 
    } 
    else 
    { 
        qDebug() << reply->header(QNetworkRequest::ContentTypeHeader).toString();
        qDebug() << reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().toString();
        qDebug() << reply->header(QNetworkRequest::ContentLengthHeader).toULongLong();
        qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
        qDebug() << reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(); 
        QFile *file = new QFile("C:/Qt/Dummy/downloaded.txt"); 
        if(file->open(QFile::Append)) 
        { 
            file->write(reply->readAll()); 
            file->flush(); 
            file->close(); 
        } 
        delete file; 
    } 
    reply->deleteLater(); 
}