test
= 400) {
throw new Exception(‘Error ‘ . $http_status_code . ‘: ‘ . curl_error($ch));
}
// Close the cURL session
curl_close($ch);
// Return the API response
return $response;
}
// Make the initial request to the terms of use page to get user consent
$terms_of_use_url = ‘https://www.puhkaeestis.ee/api/use_terms’;
$terms_of_use_response = file_get_contents($terms_of_use_url);
if (strpos($terms_of_use_response, ‘I agree to the terms of use’) === false) {
die(‘Error: Could not get user consent for API usage.’);
}
// Make the first API request for the entries service
$entries_response = get_api_response($entries_url, $version, $username, $password);
// Wait for the specified delay before making the next request
sleep($delay);
// Make the second API request for the domains service
$domains_response = get_api_response($domains_url, $version, $username, $password);
// Process the API responses as needed
// …
?>