小编Vic*_*Vic的帖子

如何在c++中使用libcurl发送POST请求并接收它?

我正在使用 c++ libcurl 向网页发送 POST 请求,但我正在努力测试它。使用的代码是:

#include <stdio.h>
#include <curl/curl.h>
#include <string>
using namespace std;
int main(void)
{
    CURL *curl = curl_easy_init();
    if(curl) {
        const char *data = "submit = 1";

        curl_easy_setopt(curl, CURLOPT_URL, "http://10.5.10.200/website/WebFrontend/backend/posttest.php");

        /* size of the POST data */
        curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 10L);

        /* pass in a pointer to the data - libcurl will not copy */
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

        curl_easy_perform(curl);
    }


    /* Perform the request, res will get the return code */ 




    /* always cleanup */ 



    return 0; …
Run Code Online (Sandbox Code Playgroud)

c++ curl http libcurl

9
推荐指数
1
解决办法
5万
查看次数

标签 统计

c++ ×1

curl ×1

http ×1

libcurl ×1