ANTICHAT

ANTICHAT (https://forum.antichat.xyz/index.php)
-   С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby (https://forum.antichat.xyz/forumdisplay.php?f=24)
-   -   Простой HTTP запрос через WinAPI и обработка JSON (https://forum.antichat.xyz/showthread.php?t=1489983)

g305noobo 23.09.2023 12:30

для себя сделал, мб кому-то понадобится 🤔

C++:





[CODE]
#include
#include
#include
#include "nlohmann/json.hpp"
int
main
(
)
{
std
::
cout

0
)
{
response_data
.
append
(
buffer
,
bytesRead
)
;
}
std
::
cout


Digger Man52 23.09.2023 12:54

Такое уж лучше в классе делать….

C++:





[CODE]
class
WebClient
{
private
:
HINTERNET hInternet
;
HINTERNET hConnect
;
public
:
bool
initialize
(
)
{
std
::
cout

0
)
{
response_data
.
append
(
buffer
,
bytesRead
)
;
}
std
::
cout



C++:





Код:

int
main
(
)
{
WebClient client
;
if
(
!
client
.
initialize
(
)
)
{
return
1
;
}
if
(
!
client
.
openUrl
(
L
"ссылка"
)
)
{
return
1
;
}
std
::
string response_data
=
client
.
readResponse
(
)
;
nlohmann
::
json json_response
;
if
(
!
client
.
parseJson
(
response_data
,
json_response
)
)
{
return
1
;
}
// жсон
return
0
;
}



Время: 13:59