If you wish to make arbitrary HTTP(S) requests to websites and APIs, e.g. to update statistics on bot lists, you can use code similar to the code below. You may pass any arbitrary POST data:
#include <dpp/dpp.h>
#include <iostream>
int main() {
std::string mypostdata = "{\"value\": 42}";
bot.request(
std::cout <<
"I got reply: " << cc.
body <<
" with HTTP status code: " << cc.
status <<
"\n";
},
mypostdata,
"application/json",
{
{"Authorization", "Bearer tokengoeshere"}
}
);
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:80
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ m_post
POST.
Definition: queues.h:191
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:63
The result of any HTTP request. Contains the headers, vital rate limit figures, and returned request ...
Definition: queues.h:111
uint16_t status
HTTP status. e.g. 200 = OK, 404 = Not found, 429 = Rate limited, etc.
Definition: queues.h:121
std::string body
Reply body.
Definition: queues.h:162
Session ready.
Definition: dispatcher.h:961