Neu zu C ++, Problem mit Curl- und Xstring -Heap -Pufferüberlauf
Posted: 21 Mar 2025, 10:08
Ich bin ziemlich neu in der Codierung und habe versucht, ein Programm zu erstellen, um Informationen über Speicherräume zu erstellen, einschließlich der Buchung. curl.
Code: Select all
std::string RentalSystem::getNewAccessToken() {
CURL* curl;
CURLcode res;
std::string responseStr;
curl = curl_easy_init();
if (curl) {
std::string postFields = "client_id=" + CLIENT_ID +
"&client_secret=" + CLIENT_SECRET +
"&refresh_token=" + REFRESH_TOKEN +
"&grant_type=refresh_token";
curl_easy_setopt(curl, CURLOPT_URL, "https://oauth2.googleapis.com/token");
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, postFields.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &RentalSystem::WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &responseStr);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr