您好我已经做了这个例子:
QUrl qurl = QUrl("someip/project/log");
QByteArray postData;
QUrl params;
params.addQueryItem("name","Myname");
postData = params.encodedQuery();
// Call the webservice
QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(serviceRequestFinished(QNetworkReply*)));
networkManager->post(QNetworkRequest(qurl), postData);
但不幸的是,这不起作用,这是服务器php方面:
$app->post('/log', 'validate');
function validate() {
$req = Slim::getInstance()->request();
$request = $req->getBody();
$session = new Sessions();
$session->bar_name = $request;
$session->save();
echo "1";
}
这里我使用Slim和activerecord进行数据库连接。我的问题是我做错了什么?我知道这不起作用,因为这应该在数据库中插入一个名称,而我的另一个问题是如何知道帖子请求是否成功?