如何使用libcurl进行HTTP发布?

我是新用的libcurl。 我不清楚如何将它用于HTTP POST请求以及如何检查结果。 我怎么能用它呢?

有关-d选项的说明,请参见手册页。 您可以多次使用它将不同的键值对传递给服务器。 一旦工作,使用--libcurl标志来查看如果您尝试使用libcurl在您的应用程序中手动执行此操作将会是什么样子。

 #include  main() { CURL *curl; curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/hello-world"); curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "foo=bar&foz=baz"); curl_easy_perform(curl); curl_easy_cleanup(curl); }