You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1022 B
C++
37 lines
1022 B
C++
#define CPPHTTPLIB_OPENSSL_SUPPORT
|
|
|
|
|
|
#include <codecvt>
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <./HTTPClient/lib/httplib.h>
|
|
#include <./HTTPClient/lib/json.hpp>
|
|
using json = nlohmann::json;
|
|
using namespace std;
|
|
int main(void) {
|
|
|
|
httplib::Client cli("https://121.36.33.250:9000");
|
|
cli.enable_server_certificate_verification(false);
|
|
|
|
json j = {{"fanId",1053}};
|
|
std::string body = j.dump();
|
|
|
|
httplib::Headers headers = {{"GroupId", "dam"}};
|
|
|
|
if (auto res = cli.Post("/services/application/api/fan_app/flangeList", headers, body, "application/json")) {
|
|
cout << res->status << endl;
|
|
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
|
std::wstring wstr =
|
|
converter.from_bytes(res->body); // 将char数组转换为宽字符数组
|
|
std::wcout.imbue(
|
|
std::locale("chs")); // 将控制台输出的编码格式改为中文编码格式
|
|
|
|
wcout << wstr << endl;
|
|
}
|
|
else {
|
|
cout << "error code: " << res.error() << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|