【发布时间】:2018-10-31 09:05:07
【问题描述】:
这是我用于 curl GET 查询的 C++ 代码(在 QT5 中)
CURL *curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/?site=http://google.fr&name=test");
curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/7.42.0");
此代码完美运行!请求已启动。
我想更改应用程序字段的路径。
我通过这个变量得到域
QString domain = ui->editDomain->text();
我试过了:
curl_easy_setopt(curl, CURLOPT_URL, domain + "?site=http://google.fr&name=test");
但是这里的查询没有启动!而且我不明白为什么... 并且编译时没有错误
【问题讨论】:
-
域名的内容是什么?
-
@user3606329 检索 GET 变量并将其写入文件的 php 文件。但它适用于硬编码的 url!
-
确保您在将网址放在一起时没有错过
/。domain.com?site=..无效。这就是我要求提供内容的原因。 -
仅供参考,Qt 中已经内置了网络功能,除非您需要一些深奥的功能,否则无需使用 Curl。