Fix rate limiting issue in example.cpp by adding delays between API calls
This commit is contained in:
@ -3,6 +3,14 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
// Helper function to wait between API calls to avoid rate limiting
|
||||
void wait_between_calls() {
|
||||
std::cout << "[privatebinapi] Waiting 12 seconds to avoid rate limiting..." << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(12));
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::cout << "PrivateBin API C++ DLL Example" << std::endl;
|
||||
@ -129,6 +137,9 @@ int main(int argc, char* argv[]) {
|
||||
std::cout << "✗ Plaintext paste failed. Error code: " << result << std::endl;
|
||||
}
|
||||
|
||||
// Wait between API calls to avoid rate limiting
|
||||
wait_between_calls();
|
||||
|
||||
// Test 2: Syntax highlighting format
|
||||
std::cout << "\n2. Testing syntax highlighting format..." << std::endl;
|
||||
char* code_paste_url = nullptr;
|
||||
@ -167,6 +178,9 @@ int main() {
|
||||
std::cout << "✗ Syntax highlighting paste failed. Error code: " << result << std::endl;
|
||||
}
|
||||
|
||||
// Wait between API calls to avoid rate limiting
|
||||
wait_between_calls();
|
||||
|
||||
// Test 3: Markdown format
|
||||
std::cout << "\n3. Testing markdown format..." << std::endl;
|
||||
char* markdown_paste_url = nullptr;
|
||||
@ -213,6 +227,9 @@ int result = create_paste(server_url, content, password, expiration, format,
|
||||
std::cout << "✗ Markdown paste failed. Error code: " << result << std::endl;
|
||||
}
|
||||
|
||||
// Wait between API calls to avoid rate limiting
|
||||
wait_between_calls();
|
||||
|
||||
// Test 4: Interactive format selection
|
||||
std::cout << "\n4. Interactive format selection..." << std::endl;
|
||||
char* interactive_paste_url = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user