有人说 c++ 发 http 请求麻烦,我不太认同,我认为一分钟内能搞定的事情,无论如何也谈不上“麻烦”
为了帮助后来人,方便以后英文不太好,常使用中文搜索的同学找到答案,我单独发到这里
1. VS 新建一个 Cpp console 工程,工程右键 -> Manage nuget packager
2. 搜索 cpprestsdk,并 点击 install

3. 复制以下代码替换 main.cpp ,然后 F5
#include <iostream>
#include <cpprest/http_client.h>
int main()
{
web::http::client::http_client client(U("https://postman-echo.com/get?a=b"));
auto rsp = client.request(web::http::methods::GET).get();
auto body = rsp.extract_string().get();
std::wcout << rsp.status_code() << "\n" << body << std::endl;
}

全程录屏:
SEO Area:
C++ 发 http 请求
Cpp 发 http 请求
怎么用 Cpp 发 http 请求
http 请求 cpp
http 请求 c++
为了帮助后来人,方便以后英文不太好,常使用中文搜索的同学找到答案,我单独发到这里
1. VS 新建一个 Cpp console 工程,工程右键 -> Manage nuget packager
2. 搜索 cpprestsdk,并 点击 install

3. 复制以下代码替换 main.cpp ,然后 F5
#include <iostream>
#include <cpprest/http_client.h>
int main()
{
web::http::client::http_client client(U("https://postman-echo.com/get?a=b"));
auto rsp = client.request(web::http::methods::GET).get();
auto body = rsp.extract_string().get();
std::wcout << rsp.status_code() << "\n" << body << std::endl;
}

全程录屏:
SEO Area:
C++ 发 http 请求
Cpp 发 http 请求
怎么用 Cpp 发 http 请求
http 请求 cpp
http 请求 c++
