PHP code example of mars-php-util / rate-limit-bypass

1. Go to this page and download the library: Download mars-php-util/rate-limit-bypass library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mars-php-util / rate-limit-bypass example snippets


function getUser($id) {
    $curl = curl("https://example-api.com/user/$id");
    curl_setopt_array($curl, $your_options);
    $response = curl_exec($curl);
    return $response;
}

use RateLimitBypass\IpRateLimitHelper;


$max_request_per_second = 10;
$proxies = [...];
$rotator = new IpRateLimitHelper($proxies, $max_request_per_second);

function getUser($id) {
    $proxy_opt = $rotator->tap();
    
    $curl = curl("https://example-api.com/user/$id");

    $your_options = array_merge_recursive($your_options, $proxy_opt);
    
    curl_setopt_array($curl, $your_options);
    $response = curl_exec($curl);
    return $response;
}

use RateLimitBypass\ApiKeyRateLimitHelper;

$max_request_per_second = 10;
$api_keys = [...];
$rotator = new ApiKeyRateLimitHelper($api_keys, $max_request_per_second);

function getUser($id) {
    $api_key = $rotator->tap(); // api key can be in query string, headers, path, ... depend on the API endpoint
    
    $curl = curl("https://example-api.com/user/$id?apiKey=$api_key");
    curl_setopt_array($curl, $your_options);
    $response = curl_exec($curl);
    return $response;
}

composer