для себя сделал, мб кому-то понадобится 🤔
C++:
#include <windows.h>
#include <wininet.h>
#include <iostream>
#include "nlohmann/json.hpp"
int main() {
std::cout << "Initializing WinINet..." << std::endl;
HINTERNET hInternet = InternetOpen(L"HTTPGET", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInternet == NULL) {
std::cout << "Error initializing WinINet" << std::endl;
return 1;
}
std::cout << "Opening URL..." << std::endl;
HINTERNET hConnect = InternetOpenUrl(hInternet, L"request link here", NULL, 0, INTERNET_FLAG_RELOAD, 0);
if (hConnect == NULL) {
std::cout << "Error opening URL" << std::endl;
InternetCloseHandle(hInternet);
return 1;
}
DWORD bytesRead;
std::string response_data;
char buffer[4096];
while (InternetReadFile(hConnect, buffer, sizeof(buffer), &bytesRead) && bytesRead > 0) {
response_data.append(buffer, bytesRead);
}
std::cout << "Closing connections..." << std::endl;
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
nlohmann::json json_response;
try {
std::cout << "Parsing JSON..." << std::endl;
json_response = nlohmann::json::parse(response_data);
}
catch (const std::exception& e) {
std::cout << "Error parsing JSON: " << e.what() << std::endl;
return 1;
}
// хаваем и перевариваем наш json
return 0;
}