DevCraft Документации
РазработкиAPI WrappersWebShare Proxy PHP WrapperEnglish

Stats and config v1.0.0

ProxyStats, ProxyConfig, GET caching, and error handling.

Plan-level config, stats/activity, cache behaviour, and retries.

ProxyConfig (v3)

$config = App::Requests('ProxyConfig')->withPlanId($planId);
$config->retrieve();
$config->status();
$config->listStats();
$config->update(['/* fields */']);

ProxyStats

$stats = App::Requests('ProxyStats');
$stats->list();
$stats->aggregate();
foreach ($stats->iterateActivities() as $activity) {
    // ...
}

Caching

Successful GET responses are cached (CACHE_LIFETIME). Mutations invalidate the resource tag. Paths containing /download/ are never cached. Bypass with forceRefresh: true on request() / Client::send(), or CACHE_ENABLED=0.

Error handling

use Devcraft\Webshare\Exceptions\ApiException;
use Devcraft\Webshare\Exceptions\RateLimitException;

try {
    App::Requests('Proxy')->query()->withFilter('mode', 'direct');
    App::Requests('Proxy')->getList();
} catch (RateLimitException $e) {
    echo "Retry after {$e->retryAfterSeconds}s\n";
} catch (ApiException $e) {
    foreach ($e->getValidationErrors() as $field => $errors) {
        foreach ($errors as $error) {
            echo "$field: {$error['message']}\n";
        }
    }
}

429/5xx: up to 3 retries with exponential backoff; Retry-After preferred; x-ratelimit-reset timestamps are converted and clamped (1–120s).

На этой странице