-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex.cpp
34 lines (26 loc) · 1.03 KB
/
ex.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "nekos-best++.hpp"
#include <stdio.h>
int
main ()
{
// init the client first to cache all available endpoints for it to be
// able to get random endpoint
nekos_best::init ();
printf ("base_url: %s\n", nekos_best::get_base_url ().c_str ());
nekos_best::QueryResult result_struct = nekos_best::fetch ("", 5);
// check the response
const nekos_best::Response res
= nekos_best::get_last_request_response ();
printf ("[RESPONSE] STATUS_CODE: %ld\n", res.status_code);
printf ("[RESPONSE] HEADERS:\n");
for (const auto header : res.headers)
printf ("\"%s\": \"%s\"\n", header.first.c_str (),
header.second.c_str ());
printf ("\n");
printf ("[RESPONSE] JSON:\n%s\n\n", res.raw_json.dump (2).c_str ());
for (const nekos_best::Meta &data : result_struct.results)
{
printf ("Got url: %s\n", data.url.c_str ());
}
return 0;
}