My idea is to have 2 (or more) urls to which I can request data at the same time. In such a way that my requests are made randomly on different URLs that return exactly the same thing.
I ask this because in many of the times my API is saturated and affects many users. Thanks in advance. (Im using PHP8.1)
<?php
function curl($url, $var = null)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_TIMEOUT, 25);
curl_setopt($curl, CURLOPT_TCP_FASTOPEN, true);
if ($var != null) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $var);
}
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if (defined('CURLOPT_DOH_URL')) {
curl_setopt($curl, CURLOPT_DOH_URL, 'https://cloudflare-dns.com/dns-query');
}
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
function getData($dataNum)
{
return substr($dataNum, 0, 6);
}
$format = $num . "|" . $expm . "|" . $expy . "|" . $cvv;
$dataNum = getData($firstdata);
$curl = curl("https://example.com/api/" . $dataNum);
$json = json_decode($curl);
// rest of code
?>