mirror of
https://github.com/tribufu/sdk-cpp
synced 2025-06-16 18:24:17 +00:00
* Add libhv and test http client * Remove cpp-httplib * Update premake5.lua * Update client.cpp * Update premake5.lua * Add more windows libs * Use mintaka http client
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
// Copyright (c) Tribufu. All Rights Reserved.
|
|
|
|
#include <tribufu/client.h>
|
|
|
|
namespace tribufu
|
|
{
|
|
TribufuClient::TribufuClient(uint64_t id, const std::string &secret)
|
|
{
|
|
this->id = id;
|
|
this->secret = secret;
|
|
this->http = HttpClient();
|
|
}
|
|
|
|
TribufuClient::~TribufuClient()
|
|
{
|
|
}
|
|
|
|
void TribufuClient::get_token()
|
|
{
|
|
try
|
|
{
|
|
std::string url = "https://api.tribufu.com/v1/servers";
|
|
FHttpResponse response = this->http.get(url);
|
|
std::cout << "status_code: " << response.status_code << std::endl;
|
|
|
|
if (response.body != nullptr)
|
|
{
|
|
json response_body = json::parse(response.body);
|
|
std::string json_str = response_body.dump(4);
|
|
std::cout << json_str << std::endl;
|
|
}
|
|
|
|
mintaka_http_free_response(response);
|
|
}
|
|
catch (std::exception &e)
|
|
{
|
|
std::cout << "exception: " << e.what() << std::endl;
|
|
}
|
|
}
|
|
}
|